简体   繁体   中英

Integrating local annotation processor project into gradle build

I've been working on a java project using Netbeans and its default ant-based build integration. Due to the insufficiency of ant I am planning on switching to a gradle-based build.

The problem is that the project is separated into three different modules:

  • Annotations-module (containing several annotation processors)
  • Database-module
  • UI-module

The UI-module and the database-module use the annotations processor from the annotations module. The UI-module depends on the database-module.

The build setup I tried looks like the following:

if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

apply plugin: "net.ltgt.apt"

dependencies {
  compile fileTree(dir: 'lib', include: ['*.jar'])

  apt files('processor/Annotations.jar')
  compileOnly files('processor/Annotations.jar')
}

I tried to integrate the module dynamically, but the gradle build process did not generate the classes which should be generated by the annotations processor. Furthermore, I've tried it with precompiled versions of the annotations-module but this didn't work either.

My questions:

  • How do I integrate the annotations-module so that the gradle build works?
  • How do I integrate the annotations-module dynamically into the build process?

Typically you'd use a project dependency

dependencies {
    compile fileTree(dir: 'lib', include: ['*.jar'])
    apt project(':annotations')
    compileOnly project(':annotations')
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM