我找到了这个好方法,想要用它来部署一些第三方文件到我们的仓库中。
命令行中的呼叫为
mvn -P deploy-libs
如果我对一个文件这样做,它会按预期完成。
<profiles>
<profile>
<id>deploy-libs</id>
<build>
<defaultGoal>deploy:deploy-file</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.4</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>openscada-external</repositoryId>
<url>${openscada.distrib.repository}</url>
<file>../openscada_opc_dcom/lib/j-interop.jar</file>
<pomFile>../openscada_opc_dcom/lib/j-interop.pom</pomFile>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
如果我使用一个带有多个执行的执行块,它就不起作用。这是一个错误还是预期行为?
<profiles>
<profile>
<id>deploy-libs</id>
<build>
<defaultGoal>deploy:deploy-file</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.4</version>
<configuration>
<repositoryId>openscada-external</repositoryId>
<url>${openscada.distrib.repository}</url>
</configuration>
<executions>
<execution>
<id>j-interop</id>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>../openscada_opc_dcom/lib/j-interop.jar</file>
<pomFile>../openscada_opc_dcom/lib/j-interop.pom</pomFile>
</configuration>
</execution>
<execution>
<id>j-interopdeps</id>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>../openscada_opc_dcom/lib/j-interopdeps.jar</file>
<pomFile>../openscada_opc_dcom/lib/j-interopdeps.pom</pomFile>
</configuration>
</execution>
<execution>
<id>jcifs</id>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>../openscada_opc_dcom/lib/jcifs-1.2.9.jar</file>
<pomFile>../openscada_opc_dcom/lib/jcifs-1.2.9.pom</pomFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
我得到的错误是:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] One or more required plugin parameters are invalid/missing for deploy:deploy-file
[0] Inside the definition for plugin maven-deploy-plugin specify the following:
<configuration>
...
<file>VALUE</file>
</configuration>
-OR-
on the command line, specify: -Dfile=VALUE
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error configuring: org.apache.maven.plugins:maven-deploy-plugin. Reason: Invalid or missing parameters: [Mojo parameter [name: file ; alias: null ]] for mojo: org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:587)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:227)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.PluginParameterException: Error configuring: org.apache.maven.plugins:maven-deploy-plugin. Reason: Invalid or missing parameters: [Mojo parameter [name: file ; alias: null ]] for mojo: org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file
at org.apache.maven.plugin.DefaultPluginManager.checkRequiredParameters(DefaultPluginManager.java:1042)
at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:659)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:429)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
有什么想法吗?