-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gazelle: Fail when errors occur (#202)
Intead of introducing a fail-fast, leverage the lifecycle to fail the extension when errors that would produce invalid build files occur.
- Loading branch information
1 parent
15f21cc
commit 8ff3022
Showing
21 changed files
with
356 additions
and
10 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
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
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
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
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,5 @@ | ||
# Maven with collision | ||
|
||
Make sure the java extension does fail on colliding packages in maven. | ||
|
||
Note that the maven_install.json file is manually crafted/invalid in order to simulate a collision on the `com.google.common.primitives` import. |
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,27 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "rules_jvm_external", | ||
sha256 = "23fe83890a77ac1a3ee143e2306ec12da4a845285b14ea13cb0df1b1e23658fe", | ||
strip_prefix = "rules_jvm_external-4.3", | ||
urls = ["https://github.com/bazelbuild/rules_jvm_external/archive/refs/tags/4.3.tar.gz"], | ||
) | ||
|
||
load("@rules_jvm_external//:defs.bzl", "maven_install") | ||
|
||
maven_install( | ||
artifacts = [ | ||
"junit:junit:4.13.1", | ||
"com.google.guava:guava:30.0-jre", | ||
], | ||
fetch_sources = True, | ||
maven_install_json = "//:maven_install.json", | ||
repositories = [ | ||
"http://uk.maven.org/maven2", | ||
"https://jcenter.bintray.com/", | ||
], | ||
) | ||
|
||
load("@maven//:defs.bzl", "pinned_maven_install") | ||
|
||
pinned_maven_install() |
1 change: 1 addition & 0 deletions
1
java/gazelle/testdata/maven_with_collision/expectedExitCode.txt
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 @@ | ||
1 |
5 changes: 5 additions & 0 deletions
5
java/gazelle/testdata/maven_with_collision/expectedStderr.txt
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,5 @@ | ||
[90m12:00AM[0m [1m[31mERR[0m[0m [1mjava/gazelle/resolve.go:XXX[0m[36m >[0m Append one of the following to BUILD.bazel: | ||
[90m12:00AM[0m [1m[31mERR[0m[0m [1mjava/gazelle/resolve.go:XXX[0m[36m >[0m # gazelle:resolve java com.google.common.primitives @maven//:com_google_guava_guava | ||
[90m12:00AM[0m [1m[31mERR[0m[0m [1mjava/gazelle/resolve.go:XXX[0m[36m >[0m # gazelle:resolve java com.google.common.primitives @maven//:com_google_guava_guava_sources | ||
[90m12:00AM[0m [31mWRN[0m [1mjava/gazelle/resolve.go:XXX[0m[36m >[0m Unable to find package for import in any dependency [36mfrom rule=[0m//src/main/java/com/example/myproject [36mpackage=[0mcom.google.common.primitives | ||
[90m12:00AM[0m [1m[31mFTL[0m[0m [1mjava/gazelle/lang.go:XXX[0m[36m >[0m the java extension encontered errors that will create invalid build files |
82 changes: 82 additions & 0 deletions
82
java/gazelle/testdata/maven_with_collision/maven_install.json
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,82 @@ | ||
{ | ||
"dependency_tree": { | ||
"dependencies": [ | ||
{ | ||
"coord": "com.google.guava:guava:30.0-jre", | ||
"dependencies": [ | ||
"com.google.code.findbugs:jsr305:3.0.2", | ||
"com.google.errorprone:error_prone_annotations:2.3.4", | ||
"com.google.guava:failureaccess:1.0.1", | ||
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", | ||
"com.google.j2objc:j2objc-annotations:1.3", | ||
"org.checkerframework:checker-qual:3.5.0" | ||
], | ||
"directDependencies": [ | ||
"com.google.code.findbugs:jsr305:3.0.2", | ||
"com.google.errorprone:error_prone_annotations:2.3.4", | ||
"com.google.guava:failureaccess:1.0.1", | ||
"com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", | ||
"com.google.j2objc:j2objc-annotations:1.3", | ||
"org.checkerframework:checker-qual:3.5.0" | ||
], | ||
"file": "v1/https/jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar", | ||
"mirror_urls": [ | ||
"http://uk.maven.org/maven2/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar", | ||
"https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar" | ||
], | ||
"packages": [ | ||
"com.google.common.annotations", | ||
"com.google.common.base", | ||
"com.google.common.base.internal", | ||
"com.google.common.cache", | ||
"com.google.common.collect", | ||
"com.google.common.escape", | ||
"com.google.common.eventbus", | ||
"com.google.common.graph", | ||
"com.google.common.hash", | ||
"com.google.common.html", | ||
"com.google.common.io", | ||
"com.google.common.math", | ||
"com.google.common.net", | ||
"com.google.common.primitives", | ||
"com.google.common.reflect", | ||
"com.google.common.util.concurrent", | ||
"com.google.common.xml", | ||
"com.google.thirdparty.publicsuffix" | ||
], | ||
"sha256": "56b292df9ec29d102820c1fd7dd581cd749d5c416c7b3aeac008dbda3b984cc2", | ||
"url": "https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar" | ||
}, | ||
{ | ||
"coord": "com.google.guava:guava:jar:sources:30.0-jre", | ||
"dependencies": [ | ||
"com.google.code.findbugs:jsr305:jar:sources:3.0.2", | ||
"com.google.errorprone:error_prone_annotations:jar:sources:2.3.4", | ||
"com.google.guava:failureaccess:jar:sources:1.0.1", | ||
"com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", | ||
"com.google.j2objc:j2objc-annotations:jar:sources:1.3", | ||
"org.checkerframework:checker-qual:jar:sources:3.5.0" | ||
], | ||
"directDependencies": [ | ||
"com.google.code.findbugs:jsr305:jar:sources:3.0.2", | ||
"com.google.errorprone:error_prone_annotations:jar:sources:2.3.4", | ||
"com.google.guava:failureaccess:jar:sources:1.0.1", | ||
"com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", | ||
"com.google.j2objc:j2objc-annotations:jar:sources:1.3", | ||
"org.checkerframework:checker-qual:jar:sources:3.5.0" | ||
], | ||
"file": "v1/https/jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar", | ||
"mirror_urls": [ | ||
"http://uk.maven.org/maven2/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar", | ||
"https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar" | ||
], | ||
"packages": [ | ||
"com.google.common.primitives" | ||
], | ||
"sha256": "daa8a245663f9027ae4b84239147d3439221839155a4d93cbab280c3e657a73d", | ||
"url": "https://jcenter.bintray.com/com/google/guava/guava/30.0-jre/guava-30.0-jre-sources.jar" | ||
} | ||
], | ||
"version": "0.1.0" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
java/gazelle/testdata/maven_with_collision/src/main/java/com/example/myproject/App.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,16 @@ | ||
package com.example.myproject; | ||
|
||
import com.google.common.primitives.Ints; | ||
|
||
/** This application compares two numbers, using the Ints.compare method from Guava. */ | ||
public class App { | ||
|
||
public static int compare(int a, int b) { | ||
return Ints.compare(a, b); | ||
} | ||
|
||
public static void main(String... args) throws Exception { | ||
App app = new App(); | ||
System.out.println("Success: " + app.compare(2, 1)); | ||
} | ||
} |
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
java/gazelle/testdata/maven_with_collision_and_resolve/BUILD.in
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 @@ | ||
# gazelle:resolve java com.google.common.primitives @maven//:com_google_guava_guava |
1 change: 1 addition & 0 deletions
1
java/gazelle/testdata/maven_with_collision_and_resolve/BUILD.out
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 @@ | ||
# gazelle:resolve java com.google.common.primitives @maven//:com_google_guava_guava |
5 changes: 5 additions & 0 deletions
5
java/gazelle/testdata/maven_with_collision_and_resolve/README.md
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,5 @@ | ||
# Maven with collision and resolve | ||
|
||
Make sure the java extension does not fail on colliding packages in maven if the correct resolve directives are present. | ||
|
||
Note that the maven_install.json file is manually crafted/invalid in order to simulate a collision on the `com.google.common.primitives` import. |
27 changes: 27 additions & 0 deletions
27
java/gazelle/testdata/maven_with_collision_and_resolve/WORKSPACE
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,27 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "rules_jvm_external", | ||
sha256 = "23fe83890a77ac1a3ee143e2306ec12da4a845285b14ea13cb0df1b1e23658fe", | ||
strip_prefix = "rules_jvm_external-4.3", | ||
urls = ["https://github.com/bazelbuild/rules_jvm_external/archive/refs/tags/4.3.tar.gz"], | ||
) | ||
|
||
load("@rules_jvm_external//:defs.bzl", "maven_install") | ||
|
||
maven_install( | ||
artifacts = [ | ||
"junit:junit:4.13.1", | ||
"com.google.guava:guava:30.0-jre", | ||
], | ||
fetch_sources = True, | ||
maven_install_json = "//:maven_install.json", | ||
repositories = [ | ||
"http://uk.maven.org/maven2", | ||
"https://jcenter.bintray.com/", | ||
], | ||
) | ||
|
||
load("@maven//:defs.bzl", "pinned_maven_install") | ||
|
||
pinned_maven_install() |
Empty file.
Oops, something went wrong.