1

ビルド時にすべての Reflections メタデータを保存する方法を示すスニペットがあり、ブートストラップ時間が短縮されます。問題は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>

私は実際に何をする必要があるのか​​ よくわかりません。

4

1 に答える 1

0

現在、maven プラグインを gradle プラグインに変換する one2one コンバーターはありません。Reflections.save2番目のスニペットを見ると、メソッドを呼び出すカスタムタスクを簡単に実装できるようです。考えられる解決策は、次のスニペットのようになります。

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")
    }
}
于 2015-11-23T07:04:07.743 に答える