Как правильно настроить структуру выходного файла с помощью сборки maven - PullRequest
0 голосов
/ 20 июня 2019

Я пытаюсь настроить проект сборки 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>

Родительский помп:

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

Чего мне не хватает?

1 Ответ

0 голосов
/ 20 июня 2019

Я понял это. Мне пришлось установить выходной каталог на / в файле дистрибутива:

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