Include custom source folder for inclusion in maven testing phase

We have an inherited project that needs us to pull some kind of user source from a user location, i.e. did this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals><goal>add-source</goal></goals>
            <configuration><sources><source>src/uom/java</source></sources></configuration>
        </execution>
    </executions>
</plugin>

This is great for building and compiling, but it doesn’t include this special path when we start adding tests to the folder /src/test/java/. It happens that mvm packageit crashes with “Class not found” when trying to compile test cases. I tried this, but it does not work:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.8</version>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals><goal>add-source</goal></goals>
            <configuration><sources><source>src/uom/java</source></sources></configuration>
        </execution>
        <execution>
            <id>add-test-source</id>
            <phase>generate-test-sources</phase>
            <goals><goal>add-source</goal></goals>
            <configuration><sources><source>src/uom/java</source></sources></configuration>
        </execution>
    </executions>
</plugin>

What is the right way to achieve this? the documentation on this is apparently not so helpful.

+4
source share
1 answer

, :

<execution>
    <id>add-test-source</id>
    <phase>generate-test-sources</phase>
    <goals><goal>add-test-source</goal></goals> <!-- was: add--source -->
    <configuration><sources><source>src/uom/java</source></sources></configuration>
</execution>
0

Source: https://habr.com/ru/post/1545603/


All Articles