Friday, 14 July 2017

How to add sources to the build for each .class file?

Desired output:

In target folder for each .class with be present .java class:
target/classes/sample/Test.java
target/classes/sample/Test.class

Solution:
In pom.xml add plugin:

<plugin>    <groupId>org.codehaus.mojo</groupId>    <artifactId>build-helper-maven-plugin</artifactId>    <version>1.9.1</version>    <executions>        <execution>            <id>add-sources-as-resources</id>            <phase>process-sources</phase>            <goals>                <goal>add-resource</goal>            </goals>            <configuration>                <resources>                    <resource>                        <directory>src/main/java</directory>                    </resource>                </resources>            </configuration>        </execution>    </executions></plugin>

No comments:

Post a Comment