[英]Maven | How can I use build-helper-maven-plugin in Gradle?
I'm trying to migrate a project from Maven to Gradle where I'm using the maven plugin build-helper-maven-plugin . 我正在尝试将项目从Maven迁移到Gradle,我正在使用maven插件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.
我查看了该站点上的文档,其中显示了如何将其添加到我的Gradle依赖项中,但没有关于如何配置它的信息。
Here's a sample of my pom.xml: 这是我的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: 我打算在gradle中配置源路径,但是,文档仅列出了如何导入依赖项,如下所示:
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? 如果在Gradle中无法实现这一点,我可以使用这个插件的替代方案吗? Thank you!
谢谢!
Well, gradle uses a slightly different model internally, so you can actually get it quite easily. 好吧,gradle在内部使用了略有不同的模型,所以你可以很容易地得到它。 Gradle use a definition of source sets for a given configuration.
Gradle使用给定配置的源集定义。 So there is a source set for main/java, where you can add more directories to.
所以有一个main / java的源集,你可以在其中添加更多的目录。 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
https://docs.gradle.org/3.3/userguide/java_plugin.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.