Maven部署文件丢失/无效的文件和/或URL

时间:2018-10-24 01:06:48

标签: java maven

运行命令时,得到以下信息。请注意,如果我要从命令行(使用-D options)运行相同的命令,它将可以正常工作。所以我做错了什么? -X和-e没有显示任何价值。我目前正在研究是否未选择我的变量,但是url值已明确定义,因此虽然可以解释文件丢失/无效的错误,但不能解释文件丢失/无效的错误。

mvn deploy:deploy-file
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building jooq-model 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-deploy-plugin:2.8.2:deploy-file (default-cli) @ jooq-model ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.280 s
[INFO] Finished at: 2018-10-23T20:24:49-04:00
[INFO] Final Memory: 6M/92M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project jooq-model: The parameters 'file', 'url' for goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file are missing or invalid -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException

我对maven-deploy-plugin使用了以下配置(告诉我是否需要更多配置):

<build>
    ....
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <id>buildnumber</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <format>{0,number}</format>
                <items>
                    <item>buildNumber</item>
                </items>                    
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
                <revisionOnScmFailure>unknownbuild</revisionOnScmFailure>   
            </configuration>
        </plugin>            
        <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.8.2</version>
            <executions>
                <execution>
                    <id>deploy-file</id>
                    <phase>deploy</phase>
                    <goals>
                        <goal>deploy-file</goal>
                    </goals>
                    <configuration>
                        <file>${project.build.directory}/${project.build.finalName}.jar</file>
                        <url>file://home/tonyb/.m2/repository</url>
                        <sources>${project.build.directory}/${project.build.finalName}-sources.jar</sources>
                        <pomFile>pom.xml</pomFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>            
    </plugins>
    <finalName>${project.artifactId}-${project.version}.${buildNumber}</finalName>
</build>

1 个答案:

答案 0 :(得分:1)

关于The deploy:deploy-file Mojo,它告诉我们

  

deploy:deploy-file mojo主要用于部署工件   不是Maven建造的。

特别是

  

如果未以某种方式指定以下必需信息,   目标将失败:

     
      
  • 要部署的工件文件
  •   
  • 组,工件,版本和包装   要部署的文件。这些可以从指定的pomFile中获取,   并使用命令行覆盖或指定。当pomFile   包含父级部分,如果满足,则可以考虑父级的groupId   没有为当前项目或在该项目上进一步指定groupId   命令行。
  •   
  • 存储库信息:要部署到的URL和   repositoryId映射到settings.xml文件中的服务器部分。如果   您没有指定repositoryId,Maven将尝试提取   使用id“远程存储库”的身份验证信息。
  •   

这意味着我们有内置的工件,例如our-artifact-1.0.jar,并希望将其部署到我们的存储库中。执行deploy:deploy-file时,我们必须通过-D传递那些必需的参数,如下例所示。

mvn deploy:deploy-file -Durl=file://C:\m2-repo \
                       -DrepositoryId=some.id \
                       -Dfile=our-artifact-1.0.jar \

然后,如果我们想在Maven Lifecycle期间部署建筑构件,请改用mvn deploy

相关问题