forked from square/dagger
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gradle test that repros issues in #3090.
This CL adds a repro test for the issues in #3090 when a transitive annotation is no longer on the classpath. Follow-up CLs will fix the remaining issues. RELNOTES=N/A PiperOrigin-RevId: 419130258
- Loading branch information
Showing
8 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
javatests/artifacts/dagger/transitive-annotation-app/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2021 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'application' | ||
} | ||
|
||
java { | ||
// Make sure the generated source is compatible with Java 7. | ||
sourceCompatibility = JavaVersion.VERSION_1_7 | ||
} | ||
|
||
dependencies { | ||
implementation project(":transitive-annotation-app:library1") | ||
implementation "com.google.dagger:dagger:$dagger_version" | ||
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" | ||
} |
31 changes: 31 additions & 0 deletions
31
javatests/artifacts/dagger/transitive-annotation-app/library1/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2021 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
} | ||
|
||
java { | ||
// Make sure the generated source is compatible with Java 7. | ||
sourceCompatibility = JavaVersion.VERSION_1_7 | ||
} | ||
|
||
dependencies { | ||
implementation project(":transitive-annotation-app:library2") | ||
implementation "com.google.dagger:dagger:$dagger_version" | ||
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version" | ||
} |
62 changes: 62 additions & 0 deletions
62
...tests/artifacts/dagger/transitive-annotation-app/library1/src/main/java/library1/Foo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2021 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package library1; | ||
|
||
import static library2.MyTransitiveAnnotation.VALUE; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
import library2.MyTransitiveAnnotation; | ||
|
||
/** | ||
* A class used to test that Dagger won't fail when non-dagger related annotations cannot be | ||
* resolved. | ||
* | ||
* <p>During the compilation of {@code :app}, {@link MyTransitiveAnnotation} will no longer be on | ||
* the classpath. In most cases, Dagger shouldn't care that the annotation isn't on the classpath | ||
*/ | ||
@Singleton | ||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-types yet. | ||
public final class Foo extends FooBase { | ||
@MyTransitiveAnnotation(VALUE) | ||
int nonDaggerField; | ||
|
||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-fields yet. | ||
@Inject int daggerField; | ||
|
||
@MyTransitiveAnnotation(VALUE) | ||
Foo(@MyTransitiveAnnotation(VALUE) String str) { | ||
super(str); | ||
} | ||
|
||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-constructors yet. | ||
@Inject | ||
Foo( | ||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-constructor parameters yet. | ||
int i) { | ||
super(i); | ||
} | ||
|
||
@MyTransitiveAnnotation(VALUE) | ||
void nonDaggerMethod(@MyTransitiveAnnotation(VALUE) int i) {} | ||
|
||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-method yet. | ||
@Inject | ||
void daggerMethod( | ||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-method parameters yet. | ||
int i) {} | ||
} |
50 changes: 50 additions & 0 deletions
50
...s/artifacts/dagger/transitive-annotation-app/library1/src/main/java/library1/FooBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2021 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package library1; | ||
|
||
import static library2.MyTransitiveAnnotation.VALUE; | ||
|
||
import javax.inject.Inject; | ||
import library2.MyTransitiveAnnotation; | ||
|
||
/** A baseclass for {@link Foo}. */ | ||
// @MyTransitiveAnnotation(VALUE): Not supported on base-types yet. | ||
public class FooBase { | ||
@MyTransitiveAnnotation(VALUE) | ||
int baseNonDaggerField; | ||
|
||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-method parameters yet. | ||
@Inject int baseDaggerField; | ||
|
||
@MyTransitiveAnnotation(VALUE) | ||
FooBase(@MyTransitiveAnnotation(VALUE) String str) {} | ||
|
||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-constructors yet. | ||
@Inject | ||
FooBase( | ||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-constructor parameters yet. | ||
int i) {} | ||
|
||
@MyTransitiveAnnotation(VALUE) | ||
void baseNonDaggerMethod(@MyTransitiveAnnotation(VALUE) int i) {} | ||
|
||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-method yet. | ||
@Inject | ||
void baseDaggerMethod( | ||
// @MyTransitiveAnnotation(VALUE): Not supported on inject-method parameters yet. | ||
int i) {} | ||
} |
25 changes: 25 additions & 0 deletions
25
javatests/artifacts/dagger/transitive-annotation-app/library2/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (C) 2021 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
} | ||
|
||
java { | ||
// Make sure the generated source is compatible with Java 7. | ||
sourceCompatibility = JavaVersion.VERSION_1_7 | ||
} |
24 changes: 24 additions & 0 deletions
24
...ger/transitive-annotation-app/library2/src/main/java/library2/MyTransitiveAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2021 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package library2; | ||
|
||
/** An annotation that is a transitive dependency of the app. */ | ||
public @interface MyTransitiveAnnotation { | ||
int value(); | ||
|
||
public static int VALUE = 0; | ||
} |
33 changes: 33 additions & 0 deletions
33
javatests/artifacts/dagger/transitive-annotation-app/src/main/java/app/MyComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2021 The Dagger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package app; | ||
|
||
import dagger.BindsInstance; | ||
import dagger.Component; | ||
import javax.inject.Singleton; | ||
import library1.Foo; | ||
|
||
@Singleton | ||
@Component | ||
interface MyComponent { | ||
Foo foo(); | ||
|
||
@Component.Factory | ||
interface Factory { | ||
MyComponent create(@BindsInstance int i); | ||
} | ||
} |