2013-03-19 86 views
1

我想用maven-deploy-plugin部署一个文件。目前,我在我的POM如下:maven-deploy-plugin repository

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-deploy-plugin</artifactId> 
      <version>2.7</version> 
      <executions> 
       <execution> 
        <id>deploy-features-xml</id> 
        <phase>deploy</phase> 
        <goals> 
         <goal>deploy-file</goal> 
        </goals> 
        <configuration> 
         <repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId> 
         <url>${project.distributionManagement.snapshotRepository.url}</url> 
         <groupId>${project.groupId}</groupId> 
         <artifactId>${project.artifactId}</artifactId> 
         <version>${project.version}</version> 
         <file>features.xml</file> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

我想基于版本快照和版本库之间切换。如果项目版本为1-SNAPSHOT,则应将文件部署到快照存储库,如果项目是1.0版,则应将文件部署到发布存储库。但是maven-deploy-plugin会对它进行硬编码吗?

回答

2

我最终的解决方案是使用build-helper-maven-plugin和maven-resources-plugin。这个设置意味着随着jar和pom和项目将部署一个xml文件,这个文件可以作为project/xml/features在maven repo中引用。

相关POM插件:

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>build-helper-maven-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>attach-artifacts</id> 
        <phase>package</phase> 
        <goals> 
         <goal>attach-artifact</goal> 
        </goals> 
        <configuration> 
         <artifacts> 
          <artifact> 
           <file>target/features/features.xml</file> 
           <type>xml</type> 
           <classifier>features</classifier> 
          </artifact> 
         </artifacts> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-resources-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>copy-features</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>copy-resources</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>target/features</outputDirectory> 
         <resources> 
          <resource> 
           <directory>src/main/features</directory> 
           <filtering>true</filtering> 
          </resource> 
         </resources> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
+0

很棒的回答。我结束了使用你的解决方案。看起来我们都在上传Karaf features.xml – 2014-11-14 18:14:52

4

此行为在默认情况下已经给出。但你应该使用repository manager。你可以通过mvn部署简单地部署一个工件,通常在SNAPSHOT版本发布的情况下,SNAPSHOT版本将进入SNAPSHOT版本库,它将发布到发布版本库。

+0

我不知道它在默认情况下给出的。该项目已经部署了一个罐子和POM。是否有另一种自动部署XML文件的方式? – 2013-03-19 09:59:34