开发者

multiple assemble results

I need to keep a status created during an artifact proceeding. So I've got the idea to bundle these state into an own zip and unpacking it in the prepare phase. Additional shall be the real result deployed as well. This result is a bundle to created files, valuable within a next artifact.

I'm trying create two result zips, but during deploy the second assembly name is ignored and always myArtifact-version.zip is deployed.

Whats wrong?

Thanks in advance, Sven

my pom looks like:

<project ...>
  <artifactId>myArtifact</artifactId>
  <groupId>de.myGroup</groupId>
  <packaging>pom</packaging>
  ...
  <dependencies>
    <dependency>
      <groupId>de.myGroup</groupId>
      <artifactId>gen-status</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
  <build>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>unpack-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/config</outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        ... proceeding generation
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>results</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptors>
                <descriptor>src/assemble/bundle-gen-results.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
          <execution>
            &l开发者_开发问答t;id>status</id>
            <phase>package</phase>
            <goals><goal>single</goal></goals>
            <configuration>
              <descriptors>
                <descriptor>src/assemble/bundle-gen-status.xml</descriptor>
              </descriptors>
              <finalName>gen-status-${project.version}</finalName>
            </configuration>
          </execution>
        </executions>
      </plugin>
  </build>
</project>

The assemblies are:

gen-results.xml:

<assembly ... >
    <id></id>
    <formats><format>zip</format></formats>
    <baseDirectory></baseDirectory>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.build.directory}/export</directory>
            <includes>
                <include>something.*/**/*.*</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

bundle-gen-status.xml

<assembly ... >
    <id></id>
    <formats><format>zip</format></formats>
    <baseDirectory></baseDirectory>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.build.directory}/config</directory>
            <includes>
                <include>status.file</include>
            </includes>
            <outputDirectory>classes/scripts</outputDirectory>
        </fileSet>
    </fileSets>

</assembly>


You can use the attach-artifact goal of build helper maven plugin to achieve this.


This allows me attaching the status file only to the current artifact. But then I'm getting a dependency cycle, when trying to add the status artifact.

<project ...>
  <artifactId>myArtifact</artifactId>
  <groupId>de.myGroup</groupId>
  <packaging>pom</packaging>
  ...
  <dependencies>
    <dependency>
      <groupId>de.myGroup</groupId>
      <artifactId>myArtifact</artifactId>
      <classifier>status</classifier>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
  ...
 <build>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>unpack-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/config</outputDirectory>
                    <includeClassifiers>status</includeClassifiers>
                </configuration>
            </execution>
        </executions>
    </plugin>
    ...
    exec
    ...
    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
      <execution>
        <id>status</id>
        <phase>package</phase>
        <goals><goal>attach-artifact</goal></goals>
        <configuration>
        <artifacts>
               <artifact>
             <file>${project.build.directory}/config/status.file</file>
             <type>file</type>
                 <classifier>status</classifier>
           </artifact>
        </artifacts>
         </configuration>
         </execution>
       </executions>
     </plugin>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜