gpt4 book ai didi

maven - 使用Gradle保存所有反射元数据

转载 作者:行者123 更新时间:2023-12-03 04:35:55 25 4
gpt4 key购买 nike

有一个片段显示了如何在构建时保存所有Reflections元数据,从而减少了引导时间here
问题是它使用Maven,而我想用Gradle做到这一点。有人可以帮我将Maven配置转换为Gradle配置吗?

<build>
<plugins>
<plugin>
<groupId>org.reflections</groupId>
<artifactId>reflections-maven</artifactId>
<version>the latest version...</version>
<executions>
<execution>
<goals>
<goal>reflections</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

同样在 github上,还有另一个代码段:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script><![CDATA[
new org.reflections.Reflections("f.q.n")
.save("${project.build.outputDirectory}/META-INF/reflections/${project.artifactId}-reflections.xml")
]]></script>
</scripts>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<!-- use latest version of Reflections -->
<version>0.9.10</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<!-- any version of Groovy \>= 1.5.0 should work here -->
<version>2.4.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>

我不太了解自己实际需要做什么。

最佳答案

当前没有将Maven插件转换为Gradle插件的one2one转换器。通过查看第二个片段,您似乎可以为此简单地实现一个自定义任务,该任务调用Reflections.save方法。可能的解决方案可能与以下代码段相似:

buildscript {
dependencies {
// for resolving reflections dependencies
mavenCentral()
}

dependencies {
// add reflections dependency to your build classpath
classpath "org.reflections:reflections:0.9.10"
}
}


task runReflections {
doLast {
org.reflections.Reflections("f.q.n").save("${sourceSet.main.output.classesDir}/META-INF/reflections/${your-xml-file-name}.xml")
}
}

关于maven - 使用Gradle保存所有反射元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33859303/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com