Skip to content

Commit

Permalink
Disable native.maven_jar: flip --incompatible_remove_native_maven_jar
Browse files Browse the repository at this point in the history
Closes #6799

Closes #10090.

Change-Id: I6308386c3a469ed1976e3d55c94694305059fb11
PiperOrigin-RevId: 280459427
  • Loading branch information
jin authored and copybara-github committed Nov 14, 2019
1 parent 22e3324 commit 489a9e5
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 512 deletions.
1 change: 0 additions & 1 deletion .bazelci/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ tasks:
- "//tools/python/..."
# Some prebuilt jars don't run with Java 11
- "-//src/test/shell/bazel:external_integration_test"
- "-//src/test/shell/bazel:maven_test"
# Re-enable once bootstrap works with Java 11
- "-//src/test/shell/bazel:bazel_bootstrap_distfile_test"
# TODO(iirina): Re-enable after #7952 was released.
Expand Down
2 changes: 0 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ platforms:
- "-//src/test/shell/bazel/android:android_ndk_integration_test"
# Some prebuilt jars don't run with Java 11
- "-//src/test/shell/bazel:external_integration_test"
- "-//src/test/shell/bazel:maven_test"
# Re-enable once bootstrap works with Java 11
- "-//src/test/shell/bazel:bazel_bootstrap_distfile_test"
# Re-enable once fixed: https://github.com/bazelbuild/bazel/issues/8162
Expand Down Expand Up @@ -235,7 +234,6 @@ platforms:
# See https://github.com/bazelbuild/bazel/issues/8033
- "-//src/tools/singlejar:output_jar_simple_test"
- "-//src/test/shell/bazel:external_integration_test"
- "-//src/test/shell/bazel:maven_test"
- "-//src/test/shell/bazel:bazel_repository_cache_test"
- "-//src/test/shell/integration:java_integration_test"
- "-//src/test/java/com/google/devtools/build/lib/sandbox/..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,16 +509,18 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl

@Option(
name = "incompatible_remove_native_maven_jar",
defaultValue = "false",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"If set to true, the native maven_jar rule is disabled; only the Starlark version "
+ "will be available")
"If set to true, the native maven_jar rule is disabled. Use rules_jvm_external to "
+ "manage your Maven dependencies transitively. rules_jvm_external also includes "
+ "a migration tool to automatically convert maven_jar usages to rules_jvm_external "
+ "Visit https://github.com/bazelbuild/rules_jvm_external for more information.")
public boolean incompatibleRemoveNativeMavenJar;

@Option(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static Builder builderWithDefaults() {
.incompatibleNoSupportToolsInActionInputs(true)
.incompatibleNoTargetOutputGroup(true)
.incompatibleRemapMainRepo(true)
.incompatibleRemoveNativeMavenJar(false)
.incompatibleRemoveNativeMavenJar(true)
.incompatibleRunShellCommandString(false)
.incompatibleRestrictNamedParams(true)
.incompatibleStringJoinRequiresStrings(true)
Expand Down
8 changes: 0 additions & 8 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -814,14 +814,6 @@ sh_test(
tags = ["no_windows"],
)

sh_test(
name = "maven_test",
size = "large",
srcs = ["maven_test.sh"],
data = [":test-deps"],
tags = ["no_windows"],
)

# To run this test, ensure that maven_dependency_plugin() and
# android_repositories() in WORKSPACE are uncommented.
sh_test(
Expand Down
87 changes: 0 additions & 87 deletions src/test/shell/bazel/bazel_repository_cache_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,41 +74,6 @@ EOF
touch BUILD
}

function setup_maven_repository() {
mkdir -p zoo
cat > zoo/BUILD <<EOF
java_binary(
name = "ball-pit",
srcs = ["BallPit.java"],
main_class = "BallPit",
deps = ["//external:mongoose"],
)
EOF

cat > zoo/BallPit.java <<EOF
import carnivore.Mongoose;
public class BallPit {
public static void main(String args[]) {
Mongoose.frolic();
}
}
EOF

serve_artifact com.example.carnivore carnivore 1.23

cat >> $(create_workspace_with_default_repos WORKSPACE) <<EOF
maven_jar(
name = 'endangered',
artifact = "com.example.carnivore:carnivore:1.23",
repository = 'http://localhost:$fileserver_port/',
sha1 = '$sha1',
sha1_src = '$sha1_src',
)
bind(name = 'mongoose', actual = '@endangered//jar')
EOF
}

# Test downloading a file from a repository.
# This creates a simple repository containing:
#
Expand Down Expand Up @@ -500,56 +465,4 @@ EOF
expect_log "Error downloading"
}

function test_maven_jar_exists_in_cache() {
setup_maven_repository

bazel fetch --repository_cache="$repo_cache_dir" //zoo:ball-pit >& $TEST_log \
|| echo "Expected fetch to succeed"

if [ ! -f $repo_cache_dir/content_addressable/sha1/$sha1/file ]; then
fail "the jar file was not cached successfully"
fi

if [ ! -f $repo_cache_dir/content_addressable/sha1/$sha1_src/file ]; then
fail "the sources file was not cached successfully"
fi
}

function test_load_cached_value_maven_jar() {
setup_maven_repository

bazel fetch --repository_cache="$repo_cache_dir" //zoo:ball-pit >& $TEST_log \
|| echo "Expected fetch to succeed"

# Kill the server
shutdown_server
bazel clean --expunge

# Fetch again
bazel fetch --repository_cache="$repo_cache_dir" //zoo:ball-pit >& $TEST_log \
|| echo "Expected fetch to succeed"

expect_log "All external dependencies fetched successfully"
}

function test_maven_jar_fail_without_cache() {
setup_maven_repository

bazel fetch --repository_cache="$repo_cache_dir" //zoo:ball-pit >& $TEST_log \
|| echo "Expected fetch to succeed"

# Kill the server
shutdown_server
bazel clean --expunge

# Clean the repository cache
rm -rf "$repo_cache_dir"

# Fetch again
bazel fetch --repository_cache="$repo_cache_dir" //zoo:ball-pit >& $TEST_log \
&& echo "Expected fetch to fail"

expect_log "Failed to fetch Maven dependency"
}

run_suite "repository cache tests"
7 changes: 4 additions & 3 deletions src/test/shell/bazel/external_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,12 @@ function test_fetch() {
serve_jar

cat >> $(create_workspace_with_default_repos WORKSPACE) <<EOF
maven_jar(
load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external")
jvm_maven_import_external(
name = 'endangered',
artifact = "com.example.carnivore:carnivore:1.23",
repository = 'http://127.0.0.1:$nc_port/',
sha1 = '$sha1',
server_urls = ['http://127.0.0.1:$nc_port/'],
artifact_sha256 = '$sha256',
)
bind(name = 'mongoose', actual = '@endangered//jar')
EOF
Expand Down
Loading

0 comments on commit 489a9e5

Please sign in to comment.