简体   繁体   English

Maven | 如何在Gradle中使用build-helper-maven-plugin?

[英]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.

相关问题 build-helper-maven-plugin导致AnnotationTypeMismatchException - build-helper-maven-plugin causing AnnotationTypeMismatchException Maven build-helper-maven-plugin 正则表达式无法使用属性作为dependency.version - Maven build-helper-maven-plugin regex unable to use property as dependency.version build-helper-maven-plugin 添加额外的源 - build-helper-maven-plugin adding additional source 使用 build-helper-maven-plugin 从 Jar 中排除文件 - Excluding Files From Jar With build-helper-maven-plugin 使用 build-helper-maven-plugin 添加生成的 Apache Avro 源 - Add generated Apache Avro source with build-helper-maven-plugin build-helper-maven-plugin add-test-resource错误 - build-helper-maven-plugin add-test-resource error 是否可以使用org.codehaus.mojo:build-helper-maven-plugin将本机dll捆绑到war文件中? - Is it possible to use the org.codehaus.mojo:build-helper-maven-plugin to bundle native dlls into a war file? build-helper-maven-plugin目标:正则表达式属性如何访问生成的属性 - build-helper-maven-plugin goal:regex-property how to access generated property maven不会识别来自build-helper-maven-plugin的execution'a标签 - maven doesnt recognize execution'a tag from build-helper-maven-plugin 停止m2e以创建在build-helper-maven-plugin中指定的不存在的源文件夹 - Stopping m2e to create non-existing source folders specified in build-helper-maven-plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM