执行maven-archetype-plugin:3.0.1:integration-test时如何指定maven-install-plugin的版本

时间:2019-06-24 04:01:17

标签: maven maven-3 apache-karaf maven-archetype maven-install-plugin

运行mvn clean install -DskipTests时发生错误。错误消息为Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install (default-install) on project feature: NoFileAssignedException: The packaging plugin for this project did not assign a main file to the project but it has attachments. Change packaging to 'pom'. -> [Help 1]

根据类似的问题(how to fix build errors for Maven Mulesoft code),我尝试将pom更改为

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>org.apache.karaf</groupId>
    <artifactId>archetypes</artifactId>
    <version>4.1.6</version>
    <relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.apache.karaf.archetypes</groupId>
<artifactId>karaf-feature-archetype</artifactId>
<packaging>maven-archetype</packaging>
<name>Apache Karaf :: Archetypes :: Feature Archetype</name>
<description>This archetype sets up an empty karaf features project.</description>

<properties>
    <archetype.version>3.0.1</archetype.version>
</properties>

<build>
    <resources>
        <resource>
            <directory>${project.basedir}/src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*</include>
            </includes>
        </resource>
    </resources>

    <extensions>
        <extension>
            <groupId>org.apache.maven.archetype</groupId>
            <artifactId>archetype-packaging</artifactId>
            <version>${archetype.version}</version>
        </extension>
    </extensions>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.5.2</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.8.2</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
                <delimiters>
                    <delimiter>^*^</delimiter>
                </delimiters>
                <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-archetype-plugin</artifactId>
        </plugin>
    </plugins>

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-archetype-plugin</artifactId>
                <version>${archetype.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

但这对我不起作用。

根据将mvn命令更改为mvn clean install -DskipTests -X的过程,我发现maven-install-plugin的版本已更改为2.5.2。但是执行maven-archetype-plugin:3.0.1:integration-test时,maven-install-plugin的版本仍然是3.0.0-M1

我的问题是:

  1. 执行maven-install-plugin时如何指定maven-archetype-plugin:3.0.1:integration-test的版本

一些好奇的问题:

  1. 为什么命令-DskipTestsmaven-archetype-plugin上不起作用,在构建项目时有什么方法可以跳过测试?
  2. maven-archetype-pluginmaven-install-plugin之间是否存在任何关系?我在Maven存储库的网站上找不到任何关系。
  3. 我正在构建karaf的源代码(来自github)。我的解决方法是删除goal.text文件夹下test中的目标,这是一个很好的工作方法吗?

一些调试输出:

E:\ws-karaf\karaf-karaf-4.1.6\archetypes\feature>mvn clean install -DskipTest -X
[DEBUG] Goal:          org.apache.maven.plugins:maven-clean-plugin:3.0.0:clean (default-clean)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (enforce-maven)
...
[DEBUG] Goal:          org.apache.felix:maven-bundle-plugin:3.5.0:cleanVersions (cleanVersions)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process (process-resource-bundles)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process (default)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-resources-plugin:3.0.2:resources (default-resources)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-resources-plugin:3.0.2:testResources (default-testResources)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-archetype-plugin:3.0.1:jar (default-jar)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-site-plugin:3.6:attach-descriptor (attach-descriptor)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-archetype-plugin:3.0.1:integration-test (default-integration-test)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-install)
...
[DEBUG] Goal:          org.apache.maven.plugins:maven-archetype-plugin:3.0.1:update-local-catalog (default-update-local-catalog)
...
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ karaf-feature-archetype ---
...
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) @ karaf-feature-archetype ---
...
[INFO] --- maven-bundle-plugin:3.5.0:cleanVersions (cleanVersions) @ karaf-feature-archetype ---
...
[INFO] --- maven-remote-resources-plugin:1.5:process (process-resource-bundles) @ karaf-feature-archetype ---
...
[INFO] --- maven-remote-resources-plugin:1.5:process (default) @ karaf-feature-archetype ---
...
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ karaf-feature-archetype ---
...
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ karaf-feature-archetype ---
...
[INFO] --- maven-archetype-plugin:3.0.1:jar (default-jar) @ karaf-feature-archetype ---
...
[INFO] --- maven-site-plugin:3.6:attach-descriptor (attach-descriptor) @ karaf-feature-archetype ---
...
[INFO] --- maven-archetype-plugin:3.0.1:integration-test (default-integration-test) @ karaf-feature-archetype ---
...
[INFO] [INFO] Error stacktraces are turned on.
[INFO] [INFO] Scanning for projects...
[INFO] [INFO]
[INFO] [INFO] ------------------------< archetype.it:feature >------------------------
[INFO] [INFO] Building feature-feature 1.0-SNAPSHOT
[INFO] [INFO] ------------------------------[ feature ]-------------------------------
[INFO] [INFO]
[INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ feature ---
[INFO] [INFO]
[INFO] [INFO] --- karaf-maven-plugin:4.1.6:features-generate-descriptor (default-features-generate-descriptor) @ feature ---
[INFO] [WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] [INFO]
[INFO] [INFO] --- karaf-maven-plugin:4.1.6:verify (default-verify) @ feature ---
[INFO] [INFO] Using repositories: https://repo.maven.apache.org/maven2@id=central
[INFO] [INFO]
[INFO] [INFO] --- maven-install-plugin:3.0.0-M1:install (default-install) @ feature ---
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time:  1.912 s
[INFO] [INFO] Finished at: 2019-06-24T11:54:31+08:00
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install (default-install) on project feature: NoFileAssignedException: The packaging plugin for this project did not assign a main file to the project but it has attachments. Change packaging to 'pom'. -> [Help 1]
[INFO] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install (default-install) on project feature: NoFileAssignedException
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
[INFO]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
[INFO]     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
[INFO]     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
[INFO]     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
[INFO]     at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
[INFO]     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
[INFO]     at java.lang.reflect.Method.invoke (Method.java:498)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] Caused by: org.apache.maven.plugin.MojoExecutionException: NoFileAssignedException
[INFO]     at org.apache.maven.plugins.install.InstallMojo.installProject (InstallMojo.java:152)
[INFO]     at org.apache.maven.plugins.install.InstallMojo.execute (InstallMojo.java:108)
[INFO]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
[INFO]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
[INFO]     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
[INFO]     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
[INFO]     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
[INFO]     at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
[INFO]     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
[INFO]     at java.lang.reflect.Method.invoke (Method.java:498)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] Caused by: org.apache.maven.shared.transfer.project.NoFileAssignedException: The packaging plugin for this project did not assign a main file to the project but it has attachments. Change packaging to 'pom'.
[INFO]     at org.apache.maven.shared.transfer.project.install.internal.DefaultProjectInstaller.install (DefaultProjectInstaller.java:116)
[INFO]     at org.apache.maven.plugins.install.InstallMojo.installProject (InstallMojo.java:140)
[INFO]     at org.apache.maven.plugins.install.InstallMojo.execute (InstallMojo.java:108)
[INFO]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
[INFO]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
[INFO]     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
[INFO]     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
[INFO]     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
[INFO]     at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
[INFO]     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
[INFO]     at java.lang.reflect.Method.invoke (Method.java:498)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] [ERROR]
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR]
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] Post-archetype-generation invoker exit code: 1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.786 s
[INFO] Finished at: 2019-06-24T11:54:32+08:00
...

0 个答案:

没有答案