Question

I am currently developing an maven based application. I want to make a bat file to run final jar. I've wrote bat file with call to java -jar... and put it into src/main/resources/runners folder. I also do not want to add this file to jar, so i excluded it from resources plugin. The problem is that bat is not copied. I've copypasted maven-resources-plugin configuration from their site, it does not work. However, i want copy bat only while calling jar:jar. Application is hosted here, so you can see details there. I tried to bind copying as such:

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <!-- here the phase you need -->
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target</outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/runners</directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Also tried <phase>package</phase> and <goal>jar</goal> (and <goal>jar:jar</goal>). No effect.

By the way: where can i read about maven phases and goals more detailed, then in official documentation (understood nothing from it)?

Was it helpful?

Solution

You could use the pre-integration-test phase, which will only be run if your jar was succesfully created by the build. You will then need to run a build through integration-test, verify, install, or deploy to ensure that the copy-resources is run.

<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <executions>
            <execution>
                <id>copy-builders</id>
                <!-- here the phase you need -->
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}</outputDirectory>
                    <resources>
                        <resource>
                            <directory>src/main/runners</directory>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>

You can read more about the lifecycle at: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top