{"id":13733495,"url":"https://github.com/tbroyer/gradle-apt-plugin","last_synced_at":"2025-05-08T09:32:07.792Z","repository":{"id":31442208,"uuid":"35005881","full_name":"tbroyer/gradle-apt-plugin","owner":"tbroyer","description":"[OBSOLETE] Gradle plugin making it easier/safer to use Java annotation processors","archived":true,"fork":false,"pushed_at":"2020-01-27T08:40:27.000Z","size":784,"stargazers_count":293,"open_issues_count":0,"forks_count":30,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-15T01:34:04.438Z","etag":null,"topics":["annotation-processing","gradle-plugin"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tbroyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-04T00:22:23.000Z","updated_at":"2024-10-27T19:05:54.000Z","dependencies_parsed_at":"2022-09-09T16:10:19.729Z","dependency_job_id":null,"html_url":"https://github.com/tbroyer/gradle-apt-plugin","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbroyer%2Fgradle-apt-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbroyer%2Fgradle-apt-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbroyer%2Fgradle-apt-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbroyer%2Fgradle-apt-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbroyer","download_url":"https://codeload.github.com/tbroyer/gradle-apt-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253036604,"owners_count":21844245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annotation-processing","gradle-plugin"],"created_at":"2024-08-03T03:00:44.154Z","updated_at":"2025-05-08T09:32:06.090Z","avatar_url":"https://github.com/tbroyer.png","language":"Groovy","funding_links":[],"categories":["Plugins","Gradle插件"],"sub_categories":["Java application development","文件同步"],"readme":"# gradle-apt-plugin\n\nThe goal of this plugin was to eventually no longer be needed, being superseded by built-in features.\nThis has become a reality with Gradle 5.2 and IntelliJ IDEA 2019.1. **tl;dr: this plugin is obsolete, don't use it.** If you're using Eclipse though, continue reading.\n\nIt originally did a few things to make it easier/safer to use Java annotation processors in a Gradle build.\nThose things are now available natively in Gradle, so what's this plugin about?\n\nIf you use older versions of Gradle (pre-4.6), you can still benefit from those features:\n* it ensures the presence of configurations for your compile-time only dependencies (annotations, generally) and annotation processors, consistently across all supported Gradle versions;\n* automatically configures the corresponding `JavaCompile` and `GroovyCompile` tasks to make use of these configurations, when the `java` or `groovy` plugin is applied.\n\nWith recent versions of Gradle (between 4.6 and 5.1), this plugin will actually only:\n* add some DSL to configure annotation processors; it is however recommended to directly configure the tasks' `options.compilerArgs`;\n* backport the `sourceSet.output.generatedSourcesDirs` Gradle 5.2 API;\n* configure `JavaCompile` and `GroovyCompile` tasks' `options.annotationProcessorGeneratedSourcesDirectory` with a _sane_ default value so you can see the generated sources in your IDE and for debugging, and avoid shipping them in your JARs.\n\nWith Gradle 5.2 and later, only the (deprecated) DSL is contributed.\n\nQuite ironically, what you'd have probably found the most useful here was the part that was only provided as a \"best effort\",\nnamely the `net.ltgt.apt-idea` or `net.ltgt.apt-eclipse` plugins that will automatically configures IntelliJ IDEA and Eclipse respectively.\n\nIf you're interested in better IDE support, please vote for those issues to eventually have built-in support:\n * [in Gradle](https://github.com/gradle/gradle/issues/2300) for the `idea` and `eclipse` plugins\n * [in Eclipse Buildship](https://github.com/eclipse/buildship/issues/329)\n * ~[in IntelliJ IDEA](https://youtrack.jetbrains.com/issue/IDEA-187868) for annotation processing in the IDE\n   (probably low priority as delegating build/run actions to Gradle is becoming the default in 2019.1)~ (fixed in 2019.3)\n\n**If you're using Eclipse, please migrate to the [`com.diffplug.eclipse.apt`](https://plugins.gradle.org/plugin/com.diffplug.eclipse.apt) plugin, which is a (maintained) fork of `net.ltgt.apt-eclipse`.**\n\n*Note: the documentation below only applies to version 0.21.\nFor version 0.20, see [the previous version of this README](https://github.com/tbroyer/gradle-apt-plugin/blob/v0.20/README.md).\nFor previous versions, please see [this even earlier version](https://github.com/tbroyer/gradle-apt-plugin/blob/648bf2810097799796fdeb327255cdc99733aabd/README.md).*\n\n## Do without the plugin\n\nThis only applies if you are using Gradle ≥ 4.3\n\n### Do without `net.ltgt.apt`\n\nDSL aside, the `net.ltgt.apt` plugin, is equivalent to the following snippet\n(unless otherwise noted, all snippets here assume Gradle ≥ 4.9, and only deal with Java projects, not Groovy ones):\n\n\u003cdetails open\u003e\n\u003csummary\u003eGroovy\u003c/summary\u003e\n\n```gradle\n// Workaround for https://github.com/gradle/gradle/issues/4956\nsourceSets.configureEach { sourceSet -\u003e\n  tasks.named(sourceSet.compileJavaTaskName).configure {\n    options.annotationProcessorGeneratedSourcesDirectory = file(\"$buildDir/generated/sources/annotationProcessor/java/${sourceSet.name}\")\n  }\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```kotlin\n// Workaround for https://github.com/gradle/gradle/issues/4956\nsourceSets.configureEach {\n    tasks.named\u003cJavaCompile\u003e(compileJavaTaskName) {\n        options.annotationProcessorGeneratedSourcesDirectory = file(\"$buildDir/generated/sources/annotationProcessor/java/${this@configureEach.name}\")\n    }\n}\n```\n\n\u003c/details\u003e\n\nWith Gradle ≤ 4.6, you'll also need to create the `\u003csourceSet\u003eAnnotationProcessor` configurations and configure the tasks' `options.annotationProcessorPath`\n(the following snippet will disable falling back to the compilation classpath to resolve annotation processors though):\n\n```gradle\nsourceSets.all {\n  def annotationProcessorConfiguration = configurations.create(name == \"main\" ? \"annotationProcessor\" : \"${name}AnnotationProcessor\")\n  tasks[compileJavaTaskName].options.annotationProcessorPath = annotationProcessorConfiguration\n}\n```\n\nAlternatively, you can selectively create configurations and configure tasks as needed:\n\n```gradle\nconfigurations {\n  annotationProcessor\n}\ncompileJava {\n  options.annotationProcessorPath = configurations.annotationProcessor\n}\n```\n\n### Do without `net.ltgt.apt-idea`\n\nIf you're delegating IDEA build/run actions to Gradle, and/or somehow don't want or need IntelliJ IDEA to do the annotation processing,\nthe `net.ltgt.apt-idea` plugin is roughly equivalent to the following snippet\n(this assumes a somewhat recent version of IntelliJ IDEA that automatically unexcludes source folders inside excluded folders):\n\n\u003cdetails open\u003e\n\u003csummary\u003eGroovy\u003c/summary\u003e\n\n```gradle\n// Workaround for https://youtrack.jetbrains.com/issue/IDEA-182577\nidea {\n  module {\n    sourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory\n    generatedSourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory\n    testSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory\n    generatedSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory\n  }\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```kotlin\n// Workaround for https://youtrack.jetbrains.com/issue/IDEA-182577\nidea {\n    module {\n        tasks.getByName\u003cJavaCompile\u003e(\"compileJava\").options.annotationProcessorGeneratedSourcesDirectory?.also {\n            // For some reason, modifying the existing collections doesn't work. We need to copy the values and then assign it back.\n            sourceDirs = sourceDirs + it\n            generatedSourceDirs = generatedSourceDirs + it\n        }\n        tasks.getByName\u003cJavaCompile\u003e(\"compileTestJava\").options.annotationProcessorGeneratedSourcesDirectory?.also {\n            // For some reason, modifying the existing collections doesn't work. We need to copy the values and then assign it back.\n            testSourceDirs = testSourceDirs + it\n            generatedSourceDirs = generatedSourceDirs + it\n        }\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eWith Gradle 5.2 (and a version of IntelliJ IDEA older than 2019.1)\u003c/summary\u003e\n\nYou can instead use:\n\n\u003cdetails open\u003e\n\u003csummary\u003eGroovy\u003c/summary\u003e\n\n```gradle\n// Workaround for https://youtrack.jetbrains.com/issue/IDEA-182577\nidea {\n  module {\n    sourceDirs += sourceSets.main.output.generatedSourcesDirs\n    generatedSourceDirs += sourceSets.main.output.generatedSourcesDirs\n    testSourceDirs += sourceSets.test.output.generatedSourcesDirs\n    generatedSourceDirs += sourceSets.test.output.generatedSourcesDirs\n  }\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```kotlin\n// Workaround for https://youtrack.jetbrains.com/issue/IDEA-182577\nidea {\n    module {\n        tasks.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).output.generatedSourcesDirs.also {\n            // For some reason, modifying the existing collections doesn't work. We need to copy the values and then assign it back.\n            sourceDirs = sourceDirs + it\n            generatedSourceDirs = generatedSourceDirs + it\n        }\n        tasks.sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME).output.generatedSourcesDirs.also {\n            // For some reason, modifying the existing collections doesn't work. We need to copy the values and then assign it back.\n            testSourceDirs = testSourceDirs + it\n            generatedSourceDirs = generatedSourceDirs + it\n        }\n    }\n}\n```\n\n\u003c/details\u003e\n\u003c/details\u003e\n\nIf you want IntelliJ IDEA to process annotations, you'll have to do some manual configuration to enable annotation processing,\nand add the annotation processors to the project's compilation classpath:\n\n\u003cdetails open\u003e\n\u003csummary\u003eGroovy\u003c/summary\u003e\n\n```gradle\n// Workaround for https://youtrack.jetbrains.com/issue/IDEA-187868\nidea {\n  module {\n    scopes.PROVIDED.plus += configurations.annotationProcessor\n    scopes.TEST.plus += configurations.testAnnotationProcessor\n  }\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```kotlin\n// Workaround for https://youtrack.jetbrains.com/issue/IDEA-187868\nidea {\n    module {\n        scopes[\"PROVIDED\"]!![\"plus\"]!!.add(configurations.annotationProcessor)\n        scopes[\"TEST\"]!![\"plus\"]!!.add(configurations.testAnnotationProcessor)\n    }\n}\n```\n\n\u003c/details\u003e\n\nIf you want to apply this configuration automatically for every project,\nyou can do this with an init script similar to the following:\n\n```gradle\nimport org.gradle.util.GradleVersion;\n\n// If running from IntelliJ IDEA (such as when importing the project)\nif (Boolean.getBoolean(\"idea.active\")) {\n  def HAS_PROCESSOR_GENERATED_SOURCES_DIR = GradleVersion.current() \u003e= GradleVersion.version(\"4.3\")\n\n  allprojects { project -\u003e\n    project.apply plugin: 'idea'\n\n    if (HAS_PROCESSOR_GENERATED_SOURCES_DIR) {\n      project.plugins.withType(JavaPlugin) {\n        project.afterEvaluate {\n          project.idea.module {\n            def mainGeneratedSources = project.tasks[\"compileJava\"].options.annotationProcessorGeneratedSourcesDirectory\n            if (mainGeneratedSources) {\n              sourceDirs += mainGeneratedSources\n              generatedSourceDirs += mainGeneratedSources\n            }\n            def testGeneratedSources = project.tasks[\"compileTestJava\"].options.annotationProcessorGeneratedSourcesDirectory\n            if (testGeneratedSources) {\n              testSourceDirs += testGeneratedSources\n              generatedSourceDirs += testGeneratedSources\n            }\n\n            // Uncomment if you want to do annotation processing in IntelliJ IDEA:\n            // def annotationProcessorConfiguration = configurations.findByName(\"annotationProcessor\")\n            // if (annotationProcessorConfiguration) {\n            //   scopes.PROVIDED.plus += annotationProcessorConfiguration\n            // }\n            // def testAnnotationProcessorConfiguration = configurations.findByName(\"testAnnotationProcessor\")\n            // if (testAnnotationProcessorConfiguration) {\n            //   scopes.TEST.plus += testAnnotationProcessorConfiguration\n            // }\n          }\n        }\n      }\n    } else {\n      // fallback to automatically applying net.ltgt.apt-idea whenever net.ltgt.apt is used\n      project.plugins.withId(\"net.ltgt.apt\") {\n        try {\n          project.apply plugin: \"net.ltgt.apt-idea\"\n          // Comment if you want to do annotation processing in IntelliJ IDEA:\n          project.plugins.withType(JavaPlugin) {\n            project.afterEvaluate {\n              project.idea.module.apt.addAptDependencies = false\n            }\n          }\n        } catch (UnknownPluginException) {\n          // ignore, in case an older version of net.ltgt.apt is being used\n          // that doesn't come with net.ltgt.apt-idea.\n        }\n      }\n    }\n  }\n}\n```\n\n### Do without `net.ltgt.apt-eclipse`\n\nThere's no easy workaround at this point, sorry :man_shrugging:\n\n## Using the plugin\n\nThe plugin is published to the Plugin Portal; see instructions there: https://plugins.gradle.org/plugin/net.ltgt.apt\n\nYou will need Gradle ≥ 4.3 to use it.\n\n## Configurations\n\nFor each `SourceSet`, a `\u003csourceSet\u003eAnnotationProcessor` configuration is available (Gradle ≥ 4.6 already provides those configurations)\n\nAs a result, the following configurations are available for any Java project:\n\n* `annotationProcessor`\n* `testAnnotationProcessor`\n\nNote that those configurations don't extend each others: `testAnnotationProcessor` doesn't extend `annotationProcessor`; those configurations are only use for their respective `JavaCompile` and `GroovyCompile` tasks.\n\n### Example usage\n\nAfter applying the plugin following the above instructions, those added configurations can be used when declaring dependencies:\n\n```gradle\ndependencies {\n  compile(\"com.google.dagger:dagger:2.18\")\n  annotationProcessor(\"com.google.dagger:dagger-compiler:2.18\")\n\n  // auto-factory contains both annotations and their processor, neither is needed at runtime\n  compileOnly(\"com.google.auto.factory:auto-factory:1.0-beta6\")\n  annotationProcessor(\"com.google.auto.factory:auto-factory:1.0-beta6\")\n\n  compileOnly(\"org.immutables:value-annotations:2.7.1\")\n  annotationProcessor(\"org.immutables:value:2.7.1\")\n}\n```\n\n## Groovy support\n\nThe plugin also configures `GroovyCompile` tasks added when the `groovy` plugin is applied.\nIt does not however configure annotation processing for Groovy sources, only for Java sources used in joint compilation.\nTo process annotations on Groovy sources, you'll have to configure your `GroovyCompile` tasks; e.g.\n\n\u003cdetails open\u003e\n\u003csummary\u003eGroovy\u003c/summary\u003e\n\n```gradle\ncompileGroovy {\n  groovyOptions.javaAnnotationProcessing = true\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```kotlin\ntasks.named\u003cGroovyCompile\u003e(\"compileGroovy\") {\n  groovyOptions.isJavaAnnotationProcessing = true\n}\n```\n\n\u003c/details\u003e\n\n## Build cache\n\nCompilation tasks are still [cacheable](https://docs.gradle.org/current/userguide/build_cache.html)\nwith the caveat that only one _language_ can be used per source set (i.e. either `src/main/java` or `src/main/groovy` but not both), unless Groovy joint compilation is used (putting Java files in `src/main/groovy`), or tasks are configured to use distinct generated sources destination directories.\n\n## Gradle Kotlin DSL\n\nThe plugin provides Kotlin extensions to make configuration easier when using the Gradle Kotlin DSL.\nThe easiest is to `import net.ltgt.gradle.apt.*` at the top of your `*.gradle.kts` file.\nMost APIs are the same as in Groovy, see below for differences.\n\n## Usage with IDEs\n\nIDE configuration is provided on a best-effort basis.\n\n### Eclipse\n\nApplying the `net.ltgt.apt-eclipse` plugin will auto-configure the generated files to enable annotation processing in Eclipse.\n\nEclipse annotation processing can be configured through a DSL, as an extension to the Eclipse JDT DSL (presented here with the default values):\n\n\u003cdetails open\u003e\n\u003csummary\u003eGroovy\u003c/summary\u003e\n\n```gradle\neclipse {\n  jdt {\n    apt {\n      // whether annotation processing is enabled in Eclipse\n      aptEnabled = compileJava.aptOptions.annotationProcessing\n      // where Eclipse will output the generated sources; values are interpreted as per project.file()\n      genSrcDir = file('.apt_generated')\n      genTestSrcDir = file('.apt_generated_tests')\n      // whether annotation processing is enabled in the editor\n      reconcileEnabled = true\n      // a map of annotation processor options; a null value will pass the argument as -Akey rather than -Akey=value\n      processorOptions = compileJava.aptOptions.processorArgs\n\n      file {\n        whenMerged { jdtApt -\u003e\n          // you can tinker with the JdtApt here\n        }\n\n        withProperties { properties -\u003e\n          // you can tinker with the Properties here\n        }\n      }\n    }\n  }\n\n  factorypath {\n    plusConfigurations = [ configurations.annotationProcessor, configurations.testAnnotationProcessor ]\n    minusConfigurations = []\n\n    file {\n      whenMerged { factorypath -\u003e\n        // you can tinker with the Factorypath here\n      }\n\n      withXml { node -\u003e\n        // you can tinker with the Node here\n      }\n    }\n  }\n}\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eKotlin\u003c/summary\u003e\n\n```kotlin\neclipse {\n  jdt {\n    apt {\n      // whether annotation processing is enabled in Eclipse\n      isAptEnabled = tasks.getByName\u003cJavaCompile\u003e(\"compileJava\").aptOptions.annotationProcessing\n      // where Eclipse will output the generated sources; values are interpreted as per project.file()\n      genSrcDir = file(\".apt_generated\")\n      genTestSrcDir = file(\".apt_generated_tests\")\n      // whether annotation processing is enabled in the editor\n      isReconcileEnabled = true\n      // a map of annotation processor options; a null value will pass the argument as -Akey rather than -Akey=value\n      processorOptions = tasks.getByName\u003cJavaCompile\u003e(\"compileJava\").aptOptions.processorArgs\n\n      file {\n        whenMerged {\n          // you can tinker with the JdtApt here, you'll need to cast 'this' to JdtApt\n        }\n\n        withProperties {\n          // you can tinker with the Properties here\n        }\n      }\n    }\n  }\n\n  factorypath {\n    plusConfigurations = [ configurations.annotationProcessor, configurations.testAnnotationProcessor ]\n    minusConfigurations = []\n\n    file {\n      whenMerged {\n        // you can tinker with the Factorypath here, you'll need to cast 'this' to Factorypath\n      }\n\n      withXml {\n        // you can tinker with the Node here\n      }\n    }\n  }\n}\n```\n\n\u003c/details\u003e\n\nWhen using Buildship, you'll have to manually run the `eclipseJdtApt` and `eclipseFactorypath` tasks to generate the Eclipse configuration files, then either run the `eclipseJdt` task or manually enable annotation processing: in the project properties → Java Compiler → Annotation Processing, check `Enable Annotation Processing`. Note that while all those tasks are depended on by the `eclipse` task, that one is incompatible with Buildship, so you have to explicitly run the two or three aforementioned tasks and _not_ run the `eclipse` task.\n\nNote that Eclipse does not distinguish main and test sources, and will process all of them using the same factory path and processor options, and the same generated source directory.\n\nIn any case, the `net.ltgt.apt-eclipse` plugin has to be applied to the project.\n\nThis can be configured system-wide for all projects using the `net.ltgt.apt` plugin by using an init script similar to the following:\n```gradle\nallprojects { project -\u003e\n  project.plugins.withId(\"net.ltgt.apt\") {\n    // automatically apply net.ltgt.apt-eclipse whenever net.ltgt.apt is used\n    try {\n      project.apply plugin: \"net.ltgt.apt-eclipse\"\n    } catch (UnknownPluginException) {\n      // ignore, in case an older version of net.ltgt.apt is being used\n      // that doesn't come with net.ltgt.apt-eclipse.\n    }\n  }\n}\n```\n\n### IntelliJ IDEA\n\nApplying the `net.ltgt.apt-idea` plugin will auto-configure the generated files to enable annotation processing in IntelliJ IDEA.\n\nWhen using the Gradle integration in IntelliJ IDEA (rather than the `idea` task), it is recommended to delegate the IDE build actions to Gradle itself starting with IDEA 2016.3: https://www.jetbrains.com/help/idea/gradle.html#delegate_build_gradle\nOtherwise, you'll have to manually enable annotation processing: in Settings… → Build, Execution, Deployment → Compiler → Annotation Processors, check `Enable annotation processing` and `Obtain processors from project classpath` (you'll have to make sure `idea.module.apt.addAptDependencies` is enabled). To mimic the Gradle behavior and generated files behavior, you can configure the production and test sources directories to `build/generated/sources/annotationProcessor/java/main` and `build/generated/sources/annotationProcessor/java/test` respectively and choose to `Store generated sources relative to:` `Module content root`.\n\nNote that unless you delegate build actions to Gradle, you'll have to uncheck `Create separate module per source set` when importing the project.\n\nIntelliJ IDEA annotation processing can be configured through a DSL, as an extension to the IDEA DSL (presented here with the default values):\n```gradle\nidea {\n  project {\n    // experimental: whether annotation processing will be configured in the IDE; only actually used with the 'idea' task.\n    configureAnnotationProcessing = true\n  }\n  module {\n    apt {\n      // whether generated sources dirs are added as generated sources root\n      addGeneratedSourcesDirs = true\n      // whether the annotationProcessor/apt and testAnnotationProcessor/testApt dependencies are added as module dependencies\n      addAptDependencies = true\n\n      // the dependency scope used for apt and/or compileOnly dependencies (when enabled above)\n      mainDependenciesScope = \"PROVIDED\" // defaults to \"COMPILE\" when using the Gradle integration in IntelliJ IDEA\n    }\n  }\n}\n```\n\nIf you always delegate build actions to Gradle, you can thus disable `idea.module.apt.addAptDependencies` system-wide (there's unfortunately no way to detect this when importing the project in IDEA, so the plugin cannot configure itself automatically), by putting the following in an [init script](https://docs.gradle.org/current/userguide/init_scripts.html), e.g. `~/.gradle/init.d/apt-idea.gradle`:\n```gradle\nallprojects { project -\u003e\n  project.plugins.withType(JavaPlugin) {\n    project.plugins.withId(\"net.ltgt.apt-idea\") {\n      project.afterEvaluate {\n        project.idea.module.apt.addAptDependencies = false\n      }\n    }\n  }\n}\n```\n\nIn any case, the `net.ltgt.apt-idea` plugin has to be applied to the project.\n\nThis can be configured system-wide for all projects using the `net.ltgt.apt` plugin by using an init script similar to the following:\n```gradle\nallprojects { project -\u003e\n  project.plugins.withId(\"net.ltgt.apt\") {\n    try {\n      // automatically apply net.ltgt.apt-idea whenever net.ltgt.apt is used\n      project.apply plugin: \"net.ltgt.apt-idea\"\n      // disable addAptDependencies (if you delegate build actions to Gradle)\n      project.plugins.withType(JavaPlugin) {\n        project.afterEvaluate {\n          project.idea.module.apt.addAptDependencies = false\n        }\n      }\n    } catch (UnknownPluginException) {\n      // ignore, in case an older version of net.ltgt.apt is being used\n      // that doesn't come with net.ltgt.apt-idea.\n    }\n  }\n}\n```\n\n## Configuration\n\nThe plugin makes many things configurable by enhancing source sets and tasks.\n\nEach source set has a couple properties (Gradle ≥ 4.6 already provides those properties natively, this plugin contributes it for earlier Gradle versions):\n\n* `annotationProcessorConfigurationName` (read-only `String`) returning the `\u003csourceSet\u003eAnnotationProcessor\u003e` configuration name\n* `annotationProcessorPath`, a `FileCollection` defaulting to the `\u003csourceSet\u003eAnnotationProcessor` configuration\n\nEach source set's `output` gains a `generatedSourcesDirs` property, a `FileCollection` aggregating the `options.annotationProcessorGeneratedSourcesDirectory` for `JavaCompile` and `GroovyCompile` corresponding to the source set.\nThis allows, for example, packaging the generated sources in a _sources JAR_, a dependency on `output.generatedSourcesDir` will automatically trigger a compilation to generate those sources.\nGradle ≥ 5.2 already provides this property natively, this plugin contributes it for earlier Gradle versions.\n\nEach `JavaCompile` and `GroovyCompile` task gains an `aptOptions` (read-only) property, itself with 3 properties:\n  * `annotationProcessing`, a `boolean` setting whether annotation processing is enabled or not; this maps to the `-proc:none` compiler argument, and defaults to `true` (meaning that argument is not passed in, and annotation processing is enabled)\n  * `processors`, a list of annotation processor class names, mapping to the `-processor` compiler argument\n  * `processorArgs`, a map of annotation processor options, each entry mapping to a `-Akey=value` compiler argument\n\nFor each source set, the corresponding `JavaCompile` and `GroovyCompile` tasks are configured such that:\n\n* `options.annotationProcessorGeneratedSourcesDirectory` is set to `${project.buildDir}/generated/sources/annotationProcessor/${sourceDirectorySet.name}/${sourceSet.name}/`, where `$sourceirectorySet.name}` will be either `java` or `groovy` (Gradle ≥ 5.2 already does that mapping natively, this plugin contributes it for earlier Gradle versions).\n* `options.annotationProcessorPath` maps to the source set's `annotationProcessorPath` (Gradle ≥ 4.6 already does that mapping natively, this plugin contributes it for earlier Gradle versions)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbroyer%2Fgradle-apt-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbroyer%2Fgradle-apt-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbroyer%2Fgradle-apt-plugin/lists"}