3
votes

I have a Spring Boot project and I'm building the jar file with mvn clean build. I need to copy a folder and a file to the root of the jar, where META-INF is located. I tried maven-resources-plugin but I can't reach my goal.

For war files I used maven-war-plugin in the past but I can't find something similar for jars.

Can anybody give me an idea?

Thanks.

2
Have you tried adding resources location to the build section of your POM?Maaaatt
Could you elaborate on this? I don't understand exactly what you mean.Cristian
You explained that you tried using maven-resources-plugin but you didn't specify what you did exactly. You can include resources in your jar using <build><resources><resource>...</resource></resources></build> as explained in the maven documentation.Maaaatt
I tried to include the resources with <resources>...</resources> but it doesn't work if the resources should be included in the root path. I need something like stackoverflow.com/questions/38833373/… but next to META-INF not inside. Still looking for an answer and testing. Thanks.Cristian
Adding my folder into the resources folder and building my project actually puts my folder at the root of my jar. Have you added your resources folder as a source folder on build path? When you extract your jar, where is located? For me, it gives me my package folder containing my classes, the META-INF folder and the one I added to resources.Maaaatt

2 Answers

0
votes

could something like the following help?

See also maven-jar-plugin

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.0.2</version>
            <configuration>
                <includes>
                    <include>**/cdi/*</include>
                    <include>**/META-INF/*</include>
                    <include>*.properties</include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
0
votes

I resolved my problem by using the maven-assembly-plugin. I created an assembly zip which contains the application jar and some other resources. This solution is specific for applications which use AWS Elastic Beanstalk and need to implement the Procfile (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html#java-se-procfile).