Commit f7fae8f0 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.3.x' into 2.4.x

Closes gh-26364
parents 75bb50bd b3275c56
...@@ -220,6 +220,8 @@ final class JavaPluginAction implements PluginApplicationAction { ...@@ -220,6 +220,8 @@ final class JavaPluginAction implements PluginApplicationAction {
objectFactory.named(LibraryElements.class, LibraryElements.JAR)); objectFactory.named(LibraryElements.class, LibraryElements.JAR));
productionRuntimeClasspath.setVisible(false); productionRuntimeClasspath.setVisible(false);
productionRuntimeClasspath.setExtendsFrom(runtimeClasspath.getExtendsFrom()); productionRuntimeClasspath.setExtendsFrom(runtimeClasspath.getExtendsFrom());
productionRuntimeClasspath.setCanBeResolved(runtimeClasspath.isCanBeResolved());
productionRuntimeClasspath.setCanBeConsumed(runtimeClasspath.isCanBeConsumed());
runtimeClasspath.extendsFrom(developmentOnly); runtimeClasspath.extendsFrom(developmentOnly);
} }
......
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -154,6 +154,18 @@ class JavaPluginActionIntegrationTests { ...@@ -154,6 +154,18 @@ class JavaPluginActionIntegrationTests {
.contains("org.gradle.dependency.bundling: external"); .contains("org.gradle.dependency.bundling: external");
} }
@TestTemplate
void productionRuntimeClasspathIsConfiguredWithResolvabilityAndConsumabilityThatMatchesRuntimeClasspath() {
String productionRuntime = this.gradleBuild.build("configurationResolvabilityAndConsumability",
"-PconfigurationName=runtimeClasspath", "-PapplyJavaPlugin").getOutput();
assertThat(productionRuntime).contains("canBeResolved: true");
assertThat(productionRuntime).contains("canBeConsumed: false");
String runtime = this.gradleBuild.build("configurationResolvabilityAndConsumability",
"-PconfigurationName=productionRuntimeClasspath", "-PapplyJavaPlugin").getOutput();
assertThat(runtime).contains("canBeResolved: true");
assertThat(runtime).contains("canBeConsumed: false");
}
private void createMinimalMainSource() throws IOException { private void createMinimalMainSource() throws IOException {
File examplePackage = new File(this.gradleBuild.getProjectDir(), "src/main/java/com/example"); File examplePackage = new File(this.gradleBuild.getProjectDir(), "src/main/java/com/example");
examplePackage.mkdirs(); examplePackage.mkdirs();
......
...@@ -35,3 +35,11 @@ task('configurationAttributes') { ...@@ -35,3 +35,11 @@ task('configurationAttributes') {
} }
} }
} }
task('configurationResolvabilityAndConsumability') {
doFirst {
def configuration = configurations.findByName(configurationName)
println "canBeResolved: ${configuration.canBeResolved}"
println "canBeConsumed: ${configuration.canBeConsumed}"
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment