Skip to content

Commit

Permalink
Merge branch '2.3.x' into 2.4.x
Browse files Browse the repository at this point in the history
Closes gh-26364
  • Loading branch information
wilkinsona committed May 5, 2021
2 parents 75bb50b + b3275c5 commit f7fae8f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ private void configureDevelopmentOnlyConfiguration(Project project) {
objectFactory.named(LibraryElements.class, LibraryElements.JAR));
productionRuntimeClasspath.setVisible(false);
productionRuntimeClasspath.setExtendsFrom(runtimeClasspath.getExtendsFrom());
productionRuntimeClasspath.setCanBeResolved(runtimeClasspath.isCanBeResolved());
productionRuntimeClasspath.setCanBeConsumed(runtimeClasspath.isCanBeConsumed());
runtimeClasspath.extendsFrom(developmentOnly);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -154,6 +154,18 @@ void productionRuntimeClasspathIsConfiguredWithAttributes() {
.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 {
File examplePackage = new File(this.gradleBuild.getProjectDir(), "src/main/java/com/example");
examplePackage.mkdirs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ task('configurationAttributes') {
println " ${attribute}: ${attributes.getAttribute(attribute)}"
}
}
}

task('configurationResolvabilityAndConsumability') {
doFirst {
def configuration = configurations.findByName(configurationName)
println "canBeResolved: ${configuration.canBeResolved}"
println "canBeConsumed: ${configuration.canBeConsumed}"
}
}

0 comments on commit f7fae8f

Please sign in to comment.