[英]Gradle - Is there a possibility to compile a single Java class before the rest of the project?
我正在將我的項目從 Maven 遷移到 Gradle,我有一個 Java 類,我需要在項目的其余部分之前編譯它。 此類創建一個將由項目使用的文件。 有誰知道如何完成這項任務? 謝謝
編輯:
以下是Maven解決方案:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
<includes>
<include>PATH/TO/CLASS/AnnotationProcessor.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>compile-project</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
AnnotationProcessor 抓取並存儲項目聲明的所有注釋數據。 這個類應該在項目的其余部分之前編譯。 至少評論區是這么說的。
在構建項目的其余部分之前,您似乎有一些需要存在的類。 解決這個問題的一種方法是將依賴項提取到一個單獨的模塊,這樣你就有了一個多項目構建......這篇文章可能會幫助你實現你想要的。
您還可以在 Gradle 中引入自定義任務,使您能夠擁有“dependsOn(someTask)”
有關更多/示例,請參閱https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:task_dependencies
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.