我正在尝试建立一个maven组装项目,以使用符合我们当前标准的文件结构来构建子模块。当我运行以下命令时:
mvn --projects :childName clean assembly:single
生成的tar的文件结构如下:
+childName-1.0-SNAPSHOT-distribution.tar
|
|
+--+childName-1.0-SNAPSHOT
|
|
+--+childName
|
|
+bin, data, actions.py
我要制作的结构是:
+childName-1.0-SNAPSHOT-distribution.tar
|
|
+--+childName
|
|
+--+bin, data, actions.py
tar下文件的确切名称对我而言并不重要;重要的是将bin文件夹及其水平上的所有其他项目上移了一个文件夹。
assembly.xml文件如下:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>distribution</id>
<formats>
<!--format>dir</format-->
<format>tar</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.parent.basedir}/src/main/resources/parentBot/</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>data/faqs.csv</exclude>
</excludes>
<outputDirectory>${artifactId}/</outputDirectory>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources/parentBot/</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>${artifactId}/</outputDirectory>
<filtered>true</filtered>
</fileSet>
</fileSets>
</assembly>
父pom是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>parentBot</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>childName</module>
</modules>
<properties>
<main.basedir>.</main.basedir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
<executions>
<execution>
<id>directories</id>
<goals>
<goal>highest-basedir</goal>
</goals>
<phase>initialize</phase>
<configuration>
<property>main.basedir</property>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<filters>
<filter>src/assembly/filters.properties</filter>
</filters>
<descriptors>
<!-- ${main.basedir} -->
<!-- ${project.parent.basedir} -->
<descriptor>${main.basedir}/src/assembly/distribution.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
</project>
我想念什么?
答案 0 :(得分:0)
我知道了。我必须在分发文件中将输出目录设置为/
:
<directory>${project.parent.basedir}/src/main/resources/parentBot/</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>data/faqs.csv</exclude>
</excludes>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources/parentBot/</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</fileSet>