3

I have a module , while building this module i want to include some resources from an external jar into my module jar.

I tried to use maven-shade-plugin but I am not able to achieve it it.

Any help is appreciated.

saurav
  • 3,424
  • 1
  • 22
  • 33

1 Answers1

3

Unpack your external resource into project target, after this unpacked resources will be included in generated artifact.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>unpack</id>
            <phase>process-resources</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>foo</groupId>
                        <artifactId>bar</artifactId>
                        <version>1.0</version>
                        <type>jar</type>
                        <includes>*.xsb, *.properties</includes>
                    </artifactItem>
                </artifactItems>
                <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                <overWriteReleases>true</overWriteReleases>
                <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
        </execution>
    </executions>
</plugin>

For non-maven file use method from this answer https://stackoverflow.com/a/3264160/516167

Community
  • 1
  • 1
MariuszS
  • 30,646
  • 12
  • 114
  • 155
  • Thanks for your answer ... but i have a constraint this external jar is not installed as a maven artifact. Is it possible to give the absolute location like (C:\external.jar)of this jar file instead of mentioning its maven coordinates ? – saurav Jan 17 '14 at 22:22