maven 3 - How to include an excluded source file for tests? -
i have initial data class should excluded in normal (default profile) build. if specify example run profile class should included. furthermore class needed tests. needs included tim.
i used excludes achieve first part, dependency test breaks testcompile goal.
<plugin> <artifactid>maven-compiler-plugin</artifactid> <executions> <execution> <id>default-compile</id> <goals> <goal>compile</goal> </goals> <configuration> <excludes> <exclude>**/initialdatabuilder.java</exclude> </excludes> </configuration> </execution> <execution> <id>default-testcompile</id> <goals> <goal>testcompile</goal> </goals> <configuration> <testincludes> <include>**/*.java</include> </testincludes> </configuration> </execution> </executions> </plugin>
what wrong config?
there no way include excluded source file tests?
maven's directory structure allows separate source/production code , test code.
the details of how layout project explained here: https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
basically, put production code in:
src/main/java
test code goes in:
src/test/java
the test code tree should include actual unit tests , supporting classes. code described belongs there. end in test jar, not production jar.
also if way, don't need mess compiler plugin settings. defaults expect.
oh 1 other thing should mention if needed profile, should make it's own maven module it's own pom file. class can reference <scope>test</scope>
dependency , other production dependency.
Comments
Post a Comment