【问题标题】:Request a custom ant task from a private repository in a maven-antrun-plugin从 maven-antrun-plugin 中的私有存储库请求自定义 ant 任务
【发布时间】:2016-03-27 01:29:21
【问题描述】:

我正在尝试执行一个自定义 ant 任务,该任务定义在一个不在 Maven Central 下的 jar 中,因此我为此创建了一个私有存储库。

存储库是用类似这样的东西定义的,它还托管了其他“私人”jar,这些 jar 被完美地发现了:

  <repositories>
        <repository>
            <id>repository.com</id>
            <name>repository.com</name>
            <url>http://repository.com/maven/</url>
        </repository>
    </repositories>

现在的问题

虽然在文档状态中仅在 部分中定义依赖项,但我发现我还需要在 pom 文件的通用 中定义依赖项。

实际上是这样的,它重复了依赖项描述:

  <dependencies>
        <dependency>
            <groupId>org.bitbucket.infinitekind</groupId>
            <artifactId>appbundler</artifactId>
            <version>1.0ea</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>local-install</id>
                        <phase>install</phase>
                        <configuration>
                            <target>
                                <taskdef name="appbundler" onerror="fail" classpathref="maven.plugin.classpath" classname="com.oracle.appbundler.AppBundlerTask"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.bitbucket.infinitekind</groupId>
                        <artifactId>appbundler</artifactId>
                        <version>1.0ea</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

这是预期的行为还是我遗漏了什么?

编辑

即使那样,似乎也没有满足依赖关系。 虽然我可以清楚地看到(由于通用依赖)jar 已下载并放置在 ~/.m2 存储库中,但 ant 任务仍然不理解它:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (local-install) on project cmmanager: Execution local-install of goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.8 or one of its dependencies could not be resolved: Failure to find org.bitbucket.infinitekind:appbundler:jar:1.0ea in https://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 -&gt; [Help 1]

【问题讨论】:

    标签: maven ant maven-antrun-plugin


    【解决方案1】:

    好吧,经过一番挖掘,我找到了答案。问题是插件依赖不是通过 repositories 部分解决的,而是通过 pluginRepositories 部分解决的。 所以这将解决问题:

    <pluginRepositories>
        <pluginRepository>
            <id>repository.com</id>
            <url>http://repository.com/maven/</url>
        </pluginRepository>
    </pluginRepositories>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-06
      • 2010-10-25
      • 2010-11-22
      • 1970-01-01
      • 1970-01-01
      • 2011-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多