且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用API​​ 3.1.1在Maven插件中使用Aether(eclipse)?

更新时间:2021-08-20 01:49:58

最后,它对我有用,我之前认为它不起作用的原因是我的pom.xml和东西中有太多依赖项没有得到正确解决。

Finally, it worked for me, and the reason I think it didn't work earlier was that I had too many dependencies in my pom.xml and things didn't get resolved correctly.

这是我使用的完整pom.xml,以便原始帖子中的代码能够正常工作。其余代码用于aether-demo,其链接也在原始帖子中提供

Here is the complete pom.xml I used in order for the code in the original post to work. Rest of the code was used from the aether-demo, the link of which is also provided in the original post

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>aether.example</groupId>
    <artifactId>my-aether-plugin</artifactId>
    <version>1.0.1-SNAPSHOT</version>
    <packaging>maven-plugin</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mavenVersion>3.1.1</mavenVersion>
        <aetherVersion>0.9.0.M4</aetherVersion>
        <mavenPluginVersion>3.2</mavenPluginVersion>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>${mavenPluginVersion}</version>
                <configuration>
                    <goalPrefix>my-aether</goalPrefix>
                    <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                </configuration>
                <executions>
                    <execution>
                        <id>mojo-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>help-goal</id>
                        <goals>
                            <goal>helpmojo</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <dependencies>  
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>${mavenVersion}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-model</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-artifact</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.sisu</groupId>
                    <artifactId>org.eclipse.sisu.plexus</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
         <dependency>
             <groupId>org.eclipse.aether</groupId>
             <artifactId>aether-api</artifactId>
             <version>${aetherVersion}</version>
         </dependency>
         <dependency>
             <groupId>org.eclipse.aether</groupId>
             <artifactId>aether-util</artifactId>
             <version>${aetherVersion}</version>
         </dependency>

         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.11</version>
             <scope>test</scope>
         </dependency>
    </dependencies>
</project>