I'm trying to migrate a project from Maven to Gradle where I'm using the maven plugin build-helper-maven-plugin . I reviewed the documentation on this site where it showed how to add this to my Gradle dependencies, but there is no information on how to configure it.
Here's a sample of my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-generated-source</id>
<phase>initialize</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${path1}/${path2}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
I intend to configure the source path in gradle, however, the documentation only listed how to import the dependency, like so:
compile 'org.codehaus.mojo:build-helper-maven-plugin:3.0.0'
In case this is not possible to accomplish in Gradle is there an alternative to this plug in I can use? Thank you!
Well, gradle uses a slightly different model internally, so you can actually get it quite easily. Gradle use a definition of source sets for a given configuration. So there is a source set for main/java, where you can add more directories to. The sourcesets are used by the compiler et al.
sourceSets {
main {
java {
srcDirs 'src/main/java'
srcDirs "${path1}/${path2}"
}
}
}
There may be additional help in the documentation, but it is sometimes hard to comprehend. https://docs.gradle.org/3.3/userguide/java_plugin.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.