Skip to content

Commit

Permalink
Problem solved
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaigorodsky committed Dec 7, 2018
1 parent b0ee073 commit d764591
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# annotation-processor-sample
Gradle 5 issue sample

## To see it working with 4.10.2
* Switch gradle version to 4.10.2 in gradle/wrapper/gradle-wrapper.properties
## To see it working with project versions 4.10.2 and 5.0
* Set gradle version to {4.10.2, 5.0} in gradle/wrapper/gradle-wrapper.properties
* In client/build.gradle pick
* Comment ``annotationProcessor "com.company:model-processor:${project.version}"``
* Uncomment ``annotationProcessor project(':model-processor')``
* Run in root directory ```./gradlew clean && ./gradlew build```
* You should see
* client/build/generated/source/apt/main/com/company/client/ImmutableClient.java
* client/build/generated/source/apt/main/com/company/client/ImmutableObjectModule.java

## To see it non-working with 5.0
* Switch gradle version to 5.0 in gradle/wrapper/gradle-wrapper.properties
* Run in root directory ```./gradlew clean && ./gradlew build```
* You should see only
* client/build/generated/source/apt/main/com/company/client/ImmutableClient.java

## To see it non-working with both versions 4.10.2 and 5.0
## To see it working with local artifact versions 4.10.2 and 5.0
* Make it work with project first as above
* Set gradle version to {4.10.2, 5.0} in gradle/wrapper/gradle-wrapper.properties
* Run in root directory ``gw publishToMavenLocal`` to publish artifacts to local repo
* In client/build.gradle
Expand All @@ -23,4 +21,5 @@ Gradle 5 issue sample
* Run in root directory ```./gradlew clean && ./gradlew build```
* You should see only
* client/build/generated/source/apt/main/com/company/client/ImmutableClient.java
* client/build/generated/source/apt/main/com/company/client/ImmutableObjectModule.java

5 changes: 2 additions & 3 deletions client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
dependencies {
annotationProcessor project(':model-processor')
// BELOW NEVER WORKS
// annotationProcessor "com.company:model-processor:${project.version}"
// annotationProcessor project(':model-processor')
annotationProcessor "com.company:model-processor:${project.version}"

compileOnly project(':model')
compileOnly group: 'org.immutables', name: 'value', version: '2.5.6'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 2 additions & 1 deletion model-processor/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
dependencies {
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc4'
compile project(':model')
compile(group: 'org.reflections', name: 'reflections', version: '0.9.11') {
exclude(module: 'annotations')
exclude(module: 'javassist')
}

compile group: 'org.immutables', name: 'value', version: '2.5.6'
compile 'com.google.auto.service:auto-service:1.0-rc4'
compileOnly 'com.google.auto.service:auto-service:1.0-rc4'
compile group: 'com.squareup', name: 'javapoet', version: '1.9.0'
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.9.1'
}

4 comments on commit d764591

@jameskraus
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating your repo with this fix. I've been looking for this same fix for about two days.

@HurryYU
Copy link

@HurryYU HurryYU commented on d764591 Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your solution, which helped me solve the problem

@swathistudyblue
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have multiple annotations in my project from lombok, slf4j, spring etc. And I created a new annotation and a processor for it. When I register this processor, all the other annotations start throwing compile errors. Is there anything specific I have to do to add to the existing list of processors.

@ishaigor
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The processor should be in a separate jar and annotationProcessor. The annotations should be in compile. Had to rework the packaging for my case.

I have multiple annotations in my project from lombok, slf4j, spring etc. And I created a new annotation and a processor for it. When I register this processor, all the other annotations start throwing compile errors. Is there anything specific I have to do to add to the existing list of processors.

Please sign in to comment.