Maven组件:包含一个位于baseDirectory父级别的文件

3
我正在使用 Maven Assembly 处理一个多模块项目,其结构如下:
    PARENT\pom.xml 
      --warModule
         -- pom.xml
         --/target/module-1.war
      --configModule
        --pom.xml
        --target/**module-2.jar**
      --distrib
        --pom.xml
        --src/assembly/assembly.xml

在我的分发模块中,我希望打包并创建一个JAR文件,其中应该只包含module-1.warmodule-2.jar文件。

我的distrib/pom.xml文件如下:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.wellsfargo.gateway.fx</groupId>
    <artifactId>distrib</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>distrib</artifactId>

<properties>
    <izpack.version>5.1.2</izpack.version>
    <izpack.base.dir>${project.build.directory}\${project.artifactId}-${project.version}-fx\izpack</izpack.base.dir>
    <izpack.standalone.compiler.version>4.3.2</izpack.standalone.compiler.version>
</properties>

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
            <descriptors>
                <descriptor>distrib/src/assembly/assembly.xml
                </descriptor>
            </descriptors>

        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

</plugins>

我的assembly.xml看起来像这样 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> izpack ${main.basedir} dir false
<fileSets>
    <fileSet>
        <directory>${project.build.directory}</directory>
        <outputDirectory>propdeploy</outputDirectory>
    </fileSet>
</fileSets>
<files>

    <file>
        <source>../warModule/target/module-1.war</source>
        <destName>foreign-exchange-v2.war</destName>
        <outputDirectory>wardeploy</outputDirectory>
    </file>
    <file>
        <source>../configModule/target/module-2.jar</source>
        <destName>module-2.jar</destName>
        <outputDirectory>wardeploy</outputDirectory>
    </file>

</files>

<dependencySets>
    <dependencySet>
        <unpack>true</unpack>
        <useProjectArtifact>true</useProjectArtifact>
    </dependencySet>
</dependencySets>

问题在于当前目录无法识别分发包的父目录,并且抱怨在位置 xxxx/distrib/warModule/target/module-v1.war 和 module-v2.war 中找不到 noSuchFileFound 文件。我该如何获取父文件夹子路径中的文件?

有什么好的想法吗?


1
在我看来,您的父POM和子POM都具有相同的artifactID:<artifactId> distrib </artifactId>。这是有意为之吗? - jspek
你是怎么构建这个项目的?例如,你是用 mvn clean install 吗?对于你的运行配置,你的基础目录是什么?它是父项目还是分发文件夹? - jspek
感谢提供指针。父ID是问题所在。 - Dinesh Arora
1个回答

1

解释:

主要问题是父POM和子POM都具有相同的artifactID。目前两个artifactIDs都是:<artifactId>distrib</artifactId>

由于不确定性,Maven假定../将带您到Parent POM的父文件夹,在这种情况下,其中没有/warModule文件夹。

解决方案:

  1. 确保每个artifactID都是唯一的。
  2. (建议)遵循Maven命名组ID、artifactID的指南:https://maven.apache.org/guides/mini/guide-naming-conventions.html

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接