手动设置程序集包名称,但安装插件会忽略它们

时间:2013-01-25 16:07:30

标签: java maven

我遇到了一些我需要配置的功能问题 这是我的POM的一部分,我将项目配置为两个不同的文件:FirstNameProject-VERSION-bin.zip和SecondNameProject-VERSION-bin.zip。 我的想法是, 来维护这些名称,即使原始人工制品很常见。

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT;     4.0.0

<groupId>com.project.my</groupId>
<artifactId>MyGenericProject</artifactId>
<name>Generic Project</name>

<version>2.0.2-SNAPSHOT</version>
...
<build>
     <plugins>
        ....
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
                <execution>
                    <id>first</id>
                    <configuration>
                        <finalName>FirstNameProject-${project.version}-bin</finalName>
                        <appendAssemblyId>false</appendAssemblyId>
                        <descriptors>
                            <descriptor>src/main/assembly/resources_first.xml</descriptor>
                        </descriptors>
                    </configuration>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
                <execution>
                    <id>second</id>
                    <configuration>
                        <finalName>FirstNameProject-${project.version}-bin</finalName>
                        <appendAssemblyId>false</appendAssemblyId>
                        <descriptors>
                            <descriptor>src/main/assembly/resources_second.xml</descriptor>
                        </descriptors>
                    </configuration>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>                   
            </executions>
        </plugin>
    </plugins>
</build>

这是正常的,我可以在mvn package日志中看到:

[INFO] --- maven-assembly-plugin:2.2.1:single (first) @ MyGenericProject ---
[INFO] Reading assembly descriptor: src/main/assembly/resources_first.xml
[INFO] Building zip: C:\MyPath\MyProject_trunk\target\FirstNameProject-2                                                                   .0.2-bin.zip
[INFO]
[INFO] --- maven-assembly-plugin:2.2.1:single (second) @ MyGenericProject ---
[INFO] Reading assembly descriptor: src/main/assembly/resources_second.xml
[INFO] Building zip: C:\MyPath\MyProject_trunk\target\SecondNameProject-2.0                                                                   .2-bin.zip

问题是,在安装期间,它只是恢复为通用名称,并将正确命名的文件安装为通用名称!

[INFO] --- maven-install-plugin:2.3.1:install(default-install)@ MyGenericProject --- [INFO]将C:\ MyPath \ MyProject_trunk \ target \ MyGenericProject-2.0.2-SNAPSHOT.jar安装到C:.m2 \ repository \ com \ project \ my \ MyGenericProject \ 2.0.2-SNAPSHOT \ MyGenericProject-2.0.2- SNAPSHOT.jar [INFO]将C:\ MyPath \ MyProject_trunk \ pom.xml安装到C:.m2 \ repository \ com \ project \ my \ MyGenericProject \ 2.0.2-SNAPSHOT \ MyGenericProject-2.0.2-SNAPSHOT.pom [INFO]将C:\ MyPath \ MyProject_trunk \ target \ FirstNameProject-2.0.2-SNAPSHOT-bin.zip安装到C:.m2 \ repository \ com \ project \ my \ MyGenericProject \ 2.0.2-SNAPSHOT \ MyGenericProject-2.0。 2-SNAPSHOT.zip

我想这是因为安装插件无法确切知道如何配置程序集插件所以我问你:我如何配置安装插件以便最终得到 FirstNameProject-VERSION-我的存储库中安装了bin.zip SecondNameProject-VERSION-bin.zip

我希望我很清楚, 感谢

1 个答案:

答案 0 :(得分:1)

听起来Maven正在将程序集工件“附加”到默认名称下的项目中。第一个选项是搜索程序集插件配置,看看是否有办法控制它。仔细看看,我没有办法做到这一点。我原本以为它会使用你的最终名称配置,但如果没有,它就不会。

我可以提供的解决方法,我希望有人可以提供更标准的内容,是configure the assembly to NOT attach itself

接下来,获取它创建的文件,即具有所需名称的文件,然后使用build-helper plugin将文件附加到所需的精确坐标下。