Sammy Cakes
Sammy Cakes

Reputation: 162

How can I add regular folder to my repository using a Maven build?

Right now if I run my project as a "Maven install", my Java Maven build creates a war file and a zip file, both under the same directory location.

How can I have this build add a regular folder to this directory location, and put the zip file inside that folder?

More Info

I tried using the maven-assembly-plugin. In repository.xml, I specify which files to put in my zip. The files are in ${project.basedir}/files. I tried putting the files inside an "extrafolder" so they're at ${project.basedir}/files/extrafolder, hoping this extra folder would be in my local repository, but Maven ignored the folder and still put both the war and zip in the same repository.

Here's the plugin in my POM:

<project>
  [...]
  <build>
    [...]
    <plugins>
      [...]
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <descriptors>
            <descriptor>src/assembly/repository.xml</descriptor>
          </descriptors>
        </configuration>
      </plugin>
   [...]
</project>

And here's the repository.xml file:

<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>repository</id>
  <formats>
    <format>tar</format>
  </formats>
<includeBaseDirectory>false</includeBaseDirectory> 
   <fileSets>
         <fileSet>  
           <directory>${project.basedir}/files</directory>
            <outputDirectory>/</outputDirectory>
             <filtered>true</filtered>
            <includes>
                <include>**/*.*</include> 
            </includes>           
        </fileSet>         
    </fileSets>  
</assembly>

Upvotes: 0

Views: 732

Answers (1)

Nancy
Nancy

Reputation: 1283

You should configure the outputDirectory as extrafolder if you need it. Example as below:

   <fileSets>
     <fileSet>  
       <directory>${project.basedir}/files</directory>
        <outputDirectory>extrafolder</outputDirectory>
         <filtered>true</filtered>
        <includes>
            <include>**/*.*</include> 
        </includes>           
    </fileSet>         
</fileSets>  

To configure the plugin to put the zip file into a specific folder as below:

      <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
      <outputDirectory>extrafolder</outputDirectory>
      <descriptors>
        <descriptor>src/assembly/repository.xml</descriptor>
      </descriptors>
    </configuration>
  </plugin>

Find more details here: https://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html#outputDirectory

Upvotes: 1

Related Questions