Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven doesn't attach non-archived files with mavenAssemblyPlugin

I have some list of files (.jil). I'd like to attach them to the build using maven-assembly-plugin.

I have no difficulty deploying these with the "zip" format.
However, the "dir" format throw an exception:

[WARNING] Assembly file: C:\Branches\project-branch\target\project\output\directory is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.

pom file:

<build>
  <plugins>

    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <version>2.2.1</version>
      <executions>

        <execution>
          <id>make-devq</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
          <configuration>
            <descriptors>
              <descriptor>
                ${basedir}/environments/dev/assembly/descriptor.xml
              </descriptor>
            </descriptors>
            <finalName>project</finalName>
            <appendAssemblyId>true</appendAssemblyId>
            <workDirectory>              
              ${project.build.directory}/${project.artifactId}/work/project
            </workDirectory>
            <outputDirectory>
              ${project.build.directory}/${project.artifactId}/output
            </outputDirectory>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

assembly descriptor:

<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>project-id</id>
    <formats>
        <format>dir</format>
    </formats>

    <includeBaseDirectory>false</includeBaseDirectory>

    <fileSets>

        <fileSet>
            <directory>${basedir}/environments/dev/jils/</directory>
            <outputDirectory>/</outputDirectory>
            <includes>
                <include>*.jil</include>
            </includes>       
        </fileSet>

    </fileSets>

</assembly>
like image 526
Sergii Lisnychyi Avatar asked Nov 24 '22 03:11

Sergii Lisnychyi


1 Answers

To add separate files you should use the build-helper-maven-plugin which offers such options to you.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <!-- add configuration for antrun or another plugin here -->
      </plugin>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>some file</file>
                  <type>extension of your file </type>
                  <classifier>optional</classifier>
                </artifact>
                ...
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

With the dir format you can't attach these files to your project. BTW: The current up-to-date version of maven-assembly-plugin is 2.4.

like image 147
khmarbaise Avatar answered Apr 26 '23 20:04

khmarbaise