0

I'm currently working on a Maven based project in which I have unit tests that generate PDF files in, let's say "C:/result" directory (I definitely don't want these files to be created within any directory from my project).

Using the maven-assembly plugin, would it be possible to create an archive file (preferably zip or jar) that gathers the files that are thus generated in "C:/result"?

Basically, my goal would be to upload this archive as a regular artefact onto a Nexus server, every time I deploy a new version of my project.

Thx in advance.

kyiu
  • 1,926
  • 1
  • 24
  • 30
  • I'm not sure why the generated PDF files couldn't just go into `target`. – Dave Newton Jan 31 '13 at 16:09
  • As a matter of fact, I don't actually know why either. It's just a constraint I got from someone at work but I definitely will ask him the exact reason why. – kyiu Jan 31 '13 at 16:23

1 Answers1

2

You'd need to define an assembly descriptor similar to:

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>bin</id>
    <formats>
        <format>zip</format>
    </formats>
    <baseDirectory>C:/</baseDirectory>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>results</directory>
            <outputDirectory>./doc</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

Save e.g. as src/assembly/bin.xml, it will be referred from the pom. The pom would contain in the build section:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
        <execution>
            <id>out</id>
            <configuration>
                <descriptors>
                    <descriptor>src/assembly/bin.xml</descriptor>
                </descriptors>
            </configuration>
            <phase>verify</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

see for more information maven assembly documentation.

MrsTang
  • 3,119
  • 1
  • 19
  • 24
  • I achieved to create the archive file I wanted with a similiar assembly descriptor but now, I want to upload it on a Nexus server along with the other artefacts. – kyiu Jan 31 '13 at 16:25
  • will this help? http://stackoverflow.com/questions/2639585/maven-assembly-plugin-install-the-created-assembly – MrsTang Jan 31 '13 at 16:35
  • That's exactly what I needed. Too bad I didn't bump into this question while browsing SO earlier. Anyway, thx a lot. – kyiu Jan 31 '13 at 22:38