Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.boot.gradle.plugin;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

Expand Down Expand Up @@ -176,6 +178,7 @@ private Configuration createAotProcessingClasspath(Project project, String taskN
classpath.setDescription("Classpath of the " + taskName + " task.");
removeDevelopmentOnly(base.getExtendsFrom(), developmentOnlyConfigurationNames)
.forEach(classpath::extendsFrom);
classpath.getIncoming().beforeResolve((dependencies) -> copyExcludeRules(base, classpath));
classpath.attributes((attributes) -> {
ProviderFactory providers = project.getProviders();
AttributeContainer baseAttributes = base.getAttributes();
Expand All @@ -187,6 +190,21 @@ private Configuration createAotProcessingClasspath(Project project, String taskN
});
}

private void copyExcludeRules(Configuration source, Configuration target) {
source.getExcludeRules().forEach((excludeRule) -> {
Map<String, String> exclusion = new HashMap<>();
String group = excludeRule.getGroup();
String module = excludeRule.getModule();
if (group != null) {
exclusion.put("group", group);
}
if (module != null) {
exclusion.put("module", module);
}
target.exclude(exclusion);
});
}

private Stream<Configuration> removeDevelopmentOnly(Set<Configuration> configurations,
Set<String> developmentOnlyConfigurationNames) {
return configurations.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,24 @@ void processAotHasTransitiveRuntimeDependenciesOnItsClasspath() {
assertThat(output).contains("org.jboss.logging" + File.separatorChar + "jboss-logging");
}

@TestTemplate
void processAotHonorsRuntimeClasspathExclusions() {
String output = this.gradleBuild.build("processAotClasspath").getOutput();
assertThat(output).doesNotContain("org.jboss.logging" + File.separatorChar + "jboss-logging");
}

@TestTemplate
void processTestAotHasTransitiveRuntimeDependenciesOnItsClasspath() {
String output = this.gradleBuild.build("processTestAotClasspath").getOutput();
assertThat(output).contains("org.jboss.logging" + File.separatorChar + "jboss-logging");
}

@TestTemplate
void processTestAotHonorsTestRuntimeClasspathExclusions() {
String output = this.gradleBuild.build("processTestAotClasspath").getOutput();
assertThat(output).doesNotContain("org.jboss.logging" + File.separatorChar + "jboss-logging");
}

@TestTemplate
void processAotDoesNotHaveDevelopmentOnlyDependenciesOnItsClasspath() {
String output = this.gradleBuild.build("processAotClasspath").getOutput();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2012-present 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.
* You may obtain a copy of the License at
*
* https://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 'org.springframework.boot'
id 'org.springframework.boot.aot'
id 'java'
}

repositories {
mavenCentral()
}

dependencies {
implementation "org.hibernate.orm:hibernate-core:6.1.1.Final"
}

configurations.runtimeClasspath {
exclude group: "org.jboss.logging", module: "jboss-logging"
}

task('processAotClasspath') {
doFirst {
tasks.findByName('processAot').classpath.files.each { println it }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2012-present 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.
* You may obtain a copy of the License at
*
* https://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 'org.springframework.boot'
id 'org.springframework.boot.aot'
id 'java'
}

repositories {
mavenCentral()
maven {
url = 'repository'
}
}

configurations.all {
resolutionStrategy {
eachDependency {
if (it.requested.group == 'org.springframework.boot') {
it.useVersion project.bootVersion
}
}
}
}

dependencies {
testImplementation "org.hibernate.orm:hibernate-core:6.1.1.Final"
}

configurations.testRuntimeClasspath {
exclude group: "org.jboss.logging", module: "jboss-logging"
}

task('processTestAotClasspath') {
doFirst {
tasks.findByName('processTestAot').classpath.files.each { println it }
}
}