工件:安装会推送超级pom而不是我定义的POM [英] artifact:install pushes the super-pom instead of the POM I define

查看:80
本文介绍了工件:安装会推送超级pom而不是我定义的POM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ant文件中定义了一个POM,该构建正常工作,从存储库中提取了正确的工件,但是,工件:安装任务将推送到"super-pom"而不是我指定的pom

I have a POM defined in the Ant file, the build works correctly, pulling the correct artifacts from the Repository, however, the artifact:install tasks pushes to 'super-pom' instead of the pom I specify

我使用以下POM文件

<project name="my-proj" default="build" 
         xmlns:artifact="antlib:org.apache.maven.artifact.ant">

  <!-- Define the Maven tasks -->
  <path id="mvn.classpath" 
        path="${env.MAVEN_HOME}/lib/maven-ant-tasks-2.1.1.jar" />
  <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
           uri="antlib:org.apache.maven.artifact.ant"
           classpathref="mvn.classpath" />


  <target name="set-deps">
    <artifact:pom id="jar.pom" packaging="jar"
                  groupId="com.me" artifactId="my-proj" 
                  version="1.0-SNAPSHOT">
      <dependency groupId="commons-logging" 
                  artifactId="commons-logging" 
                  version="1.1.1"/>
    </artifact:pom>

    <artifact:dependencies filesetId="project.jar.files" 
          pomRefId="jar.pom"/>
  </target>

  <target name="compile" depends="set-deps">
    <mkdir dir="${basedir}/output/casses"/>
    <javac srcdir="${basedir}/src" 
           destdir="${basedir}/output/classes" 
           classpathref="project.jar.files" />
  </target>

  <target name="build" depends="compile">
    <jar destfile="output/${project.name}.jar" 
         basedir="${basedir}/output/classes"/>
  </target>

  <target name="install" depends="build">
    <echo message="Installing JAR file - ${project.name}.jar"/>
    <echo message=" groupId - ${jar.pom.groupId}"/>
    <echo message="artifactId - ${jar.pom.artifactId}"/>
    <echo message=" version - ${jar.pom.version}"/>
    <artifact:install file="${basedir}/output/${project.name}.jar" 
          pomRefId="jar.pom"/>
  </target>
</project>

调用ant build将正确构建JAR文件,因此,Ant脚本正在正确设置POM(至少从依赖关系的角度来看).

Calling ant build will build the JAR file correctly, so the POM is being set up correctly by the Ant script (at least from a dependency point of view).

但是,调用ant install会导致JAR作为超级pom版本1.0安装在本地存储库上.第二次安装失败,因为存储库中已存在完整版本(1.0,尚无SNAPSHOT),并且只能覆盖SNAPSHOT版本.

However, calling ant install results in the JAR being installed on the local repository as super-pom version 1.0. installing a second time fails as a full version (1.0, no SNAPSHOT) already exists on the repository and only SNAPSHOT versions can be overwritten.

我已经在POM上设置了groupId/artifactId/version.他们怎么不被捡起来?我尝试在安装任务上再次设置这些设置(认为可能存在该任务的未记录属性),但是此任务不接受这些属性.

I've set the groupId/artifactId/version on the POM. How come they are not being picked up? I've tried setting these again on the install task (thinking maybe there were undocumented attributes for the task), but this task does not accept these attributes.

实际上,正确的值将在安装之前显示,因此POM知道它是groupId/artifactId/version,但仍然使用这些设置使安装失败.

In fact, the correct values will get displayed before the install, so the POM knows it's groupId/artifactId/version, but still fails the install using these settings.

顺便说一句,如果有帮助,我正在使用2.1.1 maven-ant-tasks JAR文件,但是我安装的Maven版本是3.0.2(不确定这些任务是否对Maven Jars进行了外部调用或该功能是否在Ant任务Jar的内部).

BTW, if it's any help, I'm using the 2.1.1 maven-ant-tasks JAR file, but the Maven version I have installed is 3.0.2 (not sure whether the tasks make external calls to the Maven Jars or if the functionality is internal to the ant task Jar).

PS.我尝试将依赖项放置在外部POM文件中,这似乎可以正常工作,pom.xml除了依赖项和groupId/artifactId/version(与上面定义的内存pom相同)之外,什么都不包含,工件:pom更改为:

PS. I've tried placing the dependencies in an external POM file and this seems to work, the pom.xml contains nothing but the dependencies and the groupId/artifactId/version (same as the in-memory pom defined above), the artifact:pom changes to:

<artifact:pom id="jar.pom" file="ant-pom.xml"/>

没有其他更改,但是ant install现在可以正常工作.这是Maven-ant-tasks中的错误还是我缺少的东西?

Nothing else changes, but ant install now works correctly. Is this a bug in the maven-ant-tasks or is there something I'm missing?

我现在在哪里工作,请使用Ant,并且我希望避免在构建过程中提供更多文件进行管理.如果需要,我会避免,但是我宁愿避免!

Where I'm working now use Ant, and I want to avoid giving more files to be managed as part of the build process. If I need to I will, but I'd rather avoid it!

推荐答案

好,我等待解决方法,而不是等待解决此问题的方法.我在安装中写出POM,然后使用基于磁盘的POM进行安装:

OK, in lieu of waiting for a fix for this issue, I went with a work-around. I write out the POM in the install, then use the disk-based POM for the install:

...
<target name="install" ...
  ...
  <artifact:writepom pomRefId="jar.pom" file="${basedir}/output/${project.name}-pom.xml" />
  <artifact:pom id="disk-based.pom" file="${basedir}/output/${project.name}-pom.xml" />

  <artifact:install file="${basedir}/output/${project.name}.jar" 
      pomRefId="disk-based.pom"/>
</target>
...

希望这会有所帮助.

这篇关于工件:安装会推送超级pom而不是我定义的POM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆