多个组装结果

发布于 2024-10-26 14:54:30 字数 4056 浏览 6 评论 0原文

我需要保留在工件处理过程中创建的状态。因此,我想到将这些状态捆绑到一个自己的 zip 中,并在准备阶段将其解压。另外还应该是部署的实际结果。此结果是创建的文件的捆绑包,在下一个工件中很有价值。

我正在尝试创建两个结果 zip,但在部署期间,第二个程序集名称将被忽略,并且始终部署 myArtifact-version.zip。

怎么了?

提前致谢, Sven

我的 pom 看起来像:

<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>
            <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>

程序集是:

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>

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>
            <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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

番薯 2024-11-02 14:54:30

您可以使用 attach-artifact 目标="http://mojo.codehaus.org/build-helper-maven-plugin/index.html" rel="nofollow">构建 helper maven 插件 来实现这一点。

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

月棠 2024-11-02 14:54:30

这允许我仅将状态文件附加到当前工件。但是当我尝试添加状态工件时,我遇到了依赖循环。

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文