【问题标题】:Maven error when doing packaging打包时的Maven错误
【发布时间】:2015-02-10 10:02:25
【问题描述】:

我在尝试在我的 Maven 应用程序的 POM.xml 文件中执行包目标时遇到问题。 尝试打包到 jar 文件时出现以下错误

Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor (default-descriptor) on project codesign-maven-plugin: Error extracting plugin descriptor: 'Goal: version already exists in the plugin descriptor for prefix: getversion
[ERROR] Existing implementation is: com.ios.plugin.VersionMojo
[ERROR] Conflicting implementation is: com.ios.plugin.VersionMojo'

我的项目已从版本控制系统中签出,并且我的项目中有一些版本控制文件,它们似乎在执行期间被包含

这是我的 POM.xml 文件

<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/maven-v4_0_0.xsd">
    <parent>
        <groupId>com.ios.ccss</groupId>
        <artifactId>ios-client</artifactId>
        <version>3.0-Beta</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>ios-maven-plugin</artifactId>
    <packaging>maven-plugin</packaging>
    <name>ios-maven-plugin</name>
    <dependencies>
        <dependency>
            <groupId>com.ios.ccss</groupId>
            <artifactId>ios-lib</artifactId>
            <version>3.0-Beta</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-plugin-api</artifactId>
            <version>2.0</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
                <executions>
                    <execution>
                        <id>default-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <packagingExcludes>**/.ade_path/**</packagingExcludes>
                    <excludes>
                        <exclude>**/.ade_path/**</exclude>
                    </excludes>
                    <testExcludes>
                        <exclude>**/.ade_path/**</exclude>
                    </testExcludes>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- this is used for inheritance merges -->
                        <phase>package</phase>
                        <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <finalName>ios-maven-plugin</finalName>
    </build>
</project>

【问题讨论】:

  • 您是否尝试过删除构建/目标目录?
  • 是的,我在触发包任务之前完成了所有清理工作

标签: java maven


【解决方案1】:

问题

在将@Mojo 注解添加到MyMojo(派生自AbstractMojo 类的类)之后,也遇到了同样的问题。

源码有问题的部分:

/**
 * Goal which touches a timestamp file.
 *
 * @goal touch
 *
 * @phase process-sources
 */
@Mojo(name = "touch", defaultPhase = LifecyclePhase.COMPILE)
public class MyMojo extends AbstractMojo {

请注意 Javadoc 和 @Mojo 注释。

解决方案

解决方案是删除MyMojo 类的Javadoc,只使用@Mojo 注释。

生成的源代码:

@Mojo(name = "touch", defaultPhase = LifecyclePhase.COMPILE)
public class MyMojo extends AbstractMojo {

来源:jigger mast: Creating a maven plugin with java 5 annotations rather than javadoc tags

【讨论】:

    猜你喜欢
    • 2014-04-17
    • 1970-01-01
    • 2019-05-05
    • 1970-01-01
    • 1970-01-01
    • 2013-05-11
    • 2017-04-15
    • 2015-08-01
    • 2013-02-19
    相关资源
    最近更新 更多