Плагин сборки Maven не собирает файлы из дескриптора - PullRequest
0 голосов
/ 11 апреля 2019

Я пытаюсь создать tar.gz с именем my-project-2.0.tar.gz, и внутри этого файла есть файл zip со всеми моими java-классами под названием my-project.zip.Причина этого кроется в некоторых файлах сценариев, которые ищут этот тип формата.

Я установил подключаемый модуль maven в мой файл pom и файлы дескрипторов.

Эта проблема заключается в том, что при запуске сборки подключаемый модуль и дескрипторы игнорируются.

Цель затмения - clean package.

<pluginManagement>
<plugins>
<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.5.5</version>
    <executions>
        <execution>
            <phase>package</phase>
            <id>assemble</id>
            <goals>
                <goal>single</goal>
            </goals>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/prep.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </execution>
        <execution>
            <phase>package</phase>
            <id>bundle</id>
            <goals>
                <goal>single</goal>
            </goals>
            <configuration>
                <finalName>my-project-2.0</finalName>
                <descriptors>
                    <descriptor>src/assembly/bundle.xml</descriptor>
                </descriptors>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </execution>
    </executions>
</plugin>
</plugins>
</pluginManagement>

Это дескриптор пакета:

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>bundle-id</id>
    <formats>
        <format>tar.gz</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>target</directory>
            <includes>
                <include>my-project.zip</include>
            </includes>
            <outputDirectory></outputDirectory>
        </fileSet>
        <fileSet>
            <directory>src/assembly</directory>
            <includes>
                <include>place.sh</include>
            </includes>
            <lineEnding>unix</lineEnding>
            <fileMode>0755</fileMode>
            <outputDirectory></outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

Это дескриптор подготовки

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>prep-id</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>target/classes</directory>
            <outputDirectory></outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

Я пытался запустить clean assembly:assembly, но я получил `НетОбнаружены дескрипторы сборки 'ошибка

Я пытался переписать мой плагин как:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.5.5</version>
    <configuration>
        <finalName>my-project-2.0</finalName>
        <descriptors>
            <descriptor>src/assembly/bundle.xml</descriptor>
        </descriptors>
        <appendAssemblyId>false</appendAssemblyId>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <id>assemble</id>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Но я не знаю, как назвать внутреннюю zip как my-project.zip

Ответы [ 2 ]

0 голосов
/ 11 апреля 2019

Основная причина, по которой моя сборка игнорировала мои дескрипторы, заключается в том, что все мои плагины были обернуты вокруг <pluginManagement> </pluginManagement>.

Это решило мою проблему

0 голосов
/ 11 апреля 2019

Когда zip-файл создается с prep.xml, имя zip-файла должно быть ${project.artifactId}-${project.version}.zip.

Итак, в вашем случае my-project - $ {project.version} .zip.

Попробуйте отредактировать bundle.xml следующим образом:

<fileSet>
  <directory>target</directory>
  <includes>
    <include>my-project-${project.version}.zip</include>
  </includes>
  <outputDirectory></outputDirectory>
</fileSet>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...