繁体   English   中英

Maven将辅助文件部署到存储库

[英]Maven deploy secondary file to repository

我希望与我的罐子,战争等一起部署XML文件。 我可以使用分类器手动执行此操作:

mvn deploy:deploy-file -DgroupId=${GROUP_ID} \
-DartifactId=$ARTIFACT_ID \
-Dversion=$VERSION \
-Dpackaging=xml \
-Dclassifier=metadata \
-Dfile=metadata.xml \
-DrepositoryId=releases \
-Durl=http://localhost/nexus/content/repositories/releases \
-DgeneratePom=false

我希望从pom.xml中的属性填充xml文件,并将其与主工件一起部署在一个简单的命令中,这适用于我们所有的内部项目。

是否可以配置部署插件来执行此操作(以及如何)? 或者我是否需要沿着其他路线(自定义maven插件)?

用于此类目的的最佳解决方案是使用build-helper-maven-plugin,如下所示:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.8</version>
    <executions>
      <execution>
        <id>attach-artifacts</id>
        <phase>package</phase>
        <goals>
          <goal>attach-artifact</goal>
        </goals>
        <configuration>
          <artifacts>
            <artifact>
              <file>x1.xml</file>
              <type>xml</type>
              <classifier>optional</classifier>
            </artifact>
            ...
          </artifacts>
        </configuration>
      </execution>
    </executions>
  </plugin>

通过这种设置,您可以使用通常的mvn deploy ,它还将部署您可以附加到常用构建工件的其他工件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM