2

试图让 antrun 插件工作:

为了让它工作,我假设我需要在 pom.xml 中包含两个条目:

依赖:

    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.7</version>
    </dependency>       

和插件:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
            <execution>
                <phase>package</phase>
                <configuration>
                    <target name="usage">
                        <echo message="This is how this target is used!"/>
                    </target>
                </configuration>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

我不知道要指定哪个阶段(我只想要一个独立的进程将我的工件推送到远程服务器 - 这就是 antrun 插件 AFAIK 的目的,无论如何。我的目的是使用这些 ant 目标作为一种方式轻松将我的整个构建从 Ant 迁移到 Maven)。我的 antrun 目标是否必须作为阶段的一部分运行?

当我尝试从 STS(debug on)运行这个('org.apache.maven.plugins:maven-antrun-plugin:antrun:1.7:package')时,我得到以下输出:

Apache Maven 3.0.4 (r1232337; 2012-01-17 10:44:56+0200)
Maven home: /home/juser/dev/workspace-sts-3.1.0.RELEASE/sagerbe-maven-trial-4/EMBEDDED
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-45-generic", arch: "amd64", family: "unix"
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from EMBEDDED/conf/settings.xml
[DEBUG] Reading user settings from /home/juser/.m2/settings.xml
[DEBUG] Using local repository at /home/juser/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /home/juser/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project org.sagerbe:web:war:1.0.0-BUILD-SNAPSHOT: (none)
[DEBUG] Looking up lifecyle mappings for packaging war from ClassRealm[plexus.core, parent: null]
[WARNING] The POM for org.apache.maven.plugins:maven-antrun-plugin:jar:antrun is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.144s
[INFO] Finished at: Thu Jun 20 10:14:39 SAST 2013
[INFO] Final Memory: 6M/111M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-antrun-plugin:antrun or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:antrun: Failure to find org.apache.maven.plugins:maven-antrun-plugin:pom:antrun in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-antrun-plugin:antrun or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:antrun
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:129)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:142)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:261)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:185)
    at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:235)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:106)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:86)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:98)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven.plugins:maven-antrun-plugin:jar:antrun
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:296)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:186)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:279)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:115)
    ... 20 more
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Failure to find org.apache.maven.plugins:maven-antrun-plugin:pom:antrun in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:281)
    ... 23 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Failure to find org.apache.maven.plugins:maven-antrun-plugin:pom:antrun in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
    at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:230)
    at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:204)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:427)
    ... 26 more
[ERROR] 
[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/PluginResolutionException

上面提到的 'PluginResolutionException' wiki 页面提供了一些建议,但我并不明智。(我可以在我的本地 m2 存储库中看到插件目录和文件,所以如果它无法从中央 maven 存储库下载它,为什么它不在我的本地存储库中查找?)

当我查看“~/.m2/repository/org/apache/maven/plugins/maven-antrun-plugin/1.7”时,我看到了这些文件:

  • m2e-lastUpdated.properties
  • maven-antrun-plugin-1.7.jar.sha1
  • maven-antrun-plugin-1.7.pom.sha1
  • maven-antrun-plugin-1.7.jar
  • maven-antrun-plugin-1.7.pom
  • _maven.repositories

...所以这肯定意味着我满足了 jar 依赖项和 pom 文件要求。

我应该配置代理吗?如果是这样,为什么?代理配置的目的是什么?

4

1 回答 1

1

对我来说,它可以像这样添加 antrun maven 依赖项:

<dependency> 
<groupId>ant</groupId> 
<artifactId>ant-optional</artifactId> 
<version>1.5.3-1</version> 
</dependency> 
<dependency>
    <groupId>org.apache.ant</groupId>
    <artifactId>ant</artifactId>
    <version>1.9.2</version>
</dependency>
<dependency>
    <groupId>org.apache.ant</groupId>
    <artifactId>ant-launcher</artifactId>
    <version>1.9.2</version>
</dependency>

<dependency>
 <groupId>com.jcraft</groupId> 
 <artifactId>jsch</artifactId> 
 <version>0.1.50</version> 
 </dependency>  

感谢您发布您的修复吉姆!!!!

于 2013-11-28T17:42:23.587 回答