Cheetah
Cheetah

Reputation: 14379

Pull files out of maven dependency in maven assembly

I have my shared service start and stop scripts in a project called bootstrapper (in a scripts folder). This project also has some bootstrapping Java code.

I have a service which has a depenedency on the bootstrapper project. I'd like to get the maven assembly session to go into the bootstrapper jar, pull out the start and stop scripts and put them in the root of the service binary (running them through the maven-filtering plugin)

If the start and stop scripts were in the service project, I would do something like this:

<fileSets>
    <fileSet>
        <filtered>true</filtered>
        <directory>${project.build.scriptSourceDirectory}</directory>
        <outputDirectory>/</outputDirectory>
        <fileMode>755</fileMode>
        <directoryMode>755</directoryMode>
    </fileSet>
</fileSets>

<dependencySets>
    <dependencySet>
        <fileMode>755</fileMode>
        <outputDirectory>/lib</outputDirectory>
        <useProjectArtifact>true</useProjectArtifact>
        <scope>runtime</scope>
    </dependencySet>
</dependencySets>

However, they are in the bootstrapper project (and need to stay there)...so how can I extract them in maven assembly?

Upvotes: 0

Views: 74

Answers (2)

Cheetah
Cheetah

Reputation: 14379

To expand on adamretter's answer, here is an example of how I did it:

<dependencySet>
    <fileMode>755</fileMode>
    <includes>
        <include>mygroup:bootstrapper</include>
    </includes>
    <outputDirectory>/</outputDirectory>
    <outputFileNameMapping></outputFileNameMapping>
    <unpack>true</unpack>
    <unpackOptions>
        <includes>
            <include>start.sh</include>
            <include>stop.sh</include>
        </includes>
        <filtered>true</filtered>
    </unpackOptions>
</dependencySet>

Upvotes: 0

adamretter
adamretter

Reputation: 3517

You can use the unpackOptions with includes of the dependencySet in the assembly plugin to achieve your needs, see: http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

Upvotes: 1

Related Questions