簡體   English   中英

如何在Gradle上觸發最小任務以運行apt插件

[英]How to trigger the minimal task on Gradle to run apt plugin

我正在創建一個編譯時注釋處理器,以在Android上生成一些代碼。

為了觸發注釋處理器,我使用了來自hvisser https://bitbucket.org/hvisser/android-apt/overviewandroid-apt插件

此刻,在我對Processor extends AbstractProcessor所做的每處更改上,我都要Processor extends AbstractProcessor我必須運行完整的/.gradlew clean build才能查看結果,即使對於很小的示例項目,這也是一個緩慢的過程。

所以我的問題是,有什么我可以用來觸發注釋處理器的gradlew tasks嗎?

我當前的./gradlew tasks的輸出為:

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for each variant.

Build tasks
-----------
assemble - Assembles the outputs of this project.
assembleAndroidTest - Assembles all the Test applications.
assembleDebug - Assembles all Debug builds.
assembleDebugAndroidTest - Assembles the android (on device) tests for the Debug build.
assembleRelease - Assembles all Release builds.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
classes - Assembles classes 'main'.
clean - Deletes the build directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources
jar - Assembles a jar archive containing the main classes.
mockableAndroidJar - Creates a version of android.jar that's suitable for unit tests.
testClasses - Assembles classes 'test'.

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Documentation tasks
-------------------
javadoc - Generates Javadoc API documentation for the main source code.

Help tasks
----------
components - Displays the components produced by root project 'Decorator'. [incubating]
dependencies - Displays all dependencies declared in root project 'Decorator'.
dependencyInsight - Displays the insight into a specific dependency in root project 'Decorator'.
help - Displays a help message.
projects - Displays the sub-projects of root project 'Decorator'.
properties - Displays the properties of root project 'Decorator'.
tasks - Displays the tasks runnable from root project 'Decorator' (some of the displayed tasks may belong to subprojects).

Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.

Verification tasks
------------------
check - Runs all checks.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedAndroidTestDebug - Installs and runs the tests for Debug build on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
test - Runs the unit tests.
testDebug - Run unit tests for the debug build.
testRelease - Run unit tests for the release build.

Other tasks
-----------
jarDebugClasses
jarReleaseClasses

編譯時會生成源代碼。 因此,您需要運行gradlew cleanCompileDebugSources compileDebugSources 這是相同的是什么,當你的Android Studio的運行make從你的項目build菜單。

如果您將注釋處理器作為項目的一部分進行開發,則可以在android-apt使用processor選項,而無需打包處理器項目。 這是假設您將處理器模塊作為apt project(':myprocessor')依賴項( compile也將起作用)。

apt {
    processor "my.class.name"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM