【问题标题】:Maven assembly : including a file at the parent level of baseDirectoryMaven 程序集:包括 baseDirectory 父级的文件
【发布时间】:2018-01-12 18:05:01
【问题描述】:

我正在为一个看起来像这样的多模块项目使用 maven 程序集

    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 文件。 p>

我的 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} 目录 假的

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

问题是当前没有识别分发的父目录并抱怨 noSuchFileFound 在位置 xxxx/distrib/warModule/target/module-v1.war 和 module-v2 相同。战争。如何获取父文件夹子路径中的文件?

有什么想法吗?

【问题讨论】:

  • 在我看来,您的父 POM 和子 POM 都具有相同的 artifactID:&lt;artifactId&gt;distrib&lt;/artifactId&gt;。这是故意的吗?
  • 你是如何构建项目的?例如,您使用的是mvn clean install?对于您的运行配置,您的基本目录是什么?是父项目还是 Distro 文件夹?
  • 感谢您的指点。家长 ID 是问题

标签: java maven


【解决方案1】:

解释

主要问题是父 POM 和子 POM 都具有相同的 artifactID。 目前两个 artifactID 都是:&lt;artifactId&gt;distrib&lt;/artifactId&gt;

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

解决方案:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-11
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    • 2014-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多