IntegrationTestPlugin.java (spring-boot-2.7.3) | : | IntegrationTestPlugin.java (spring-boot-2.7.4) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright 2012-2020 the original author or authors. | * Copyright 2012-2022 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. | |||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | |||
* | * | |||
* https://www.apache.org/licenses/LICENSE-2.0 | * https://www.apache.org/licenses/LICENSE-2.0 | |||
* | * | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | |||
* limitations under the License. | * limitations under the License. | |||
*/ | */ | |||
package org.springframework.boot.build.test; | package org.springframework.boot.build.test; | |||
import org.gradle.api.Plugin; | import org.gradle.api.Plugin; | |||
import org.gradle.api.Project; | import org.gradle.api.Project; | |||
import org.gradle.api.plugins.JavaPlugin; | import org.gradle.api.plugins.JavaPlugin; | |||
import org.gradle.api.plugins.JavaPluginConvention; | import org.gradle.api.plugins.JavaPluginExtension; | |||
import org.gradle.api.tasks.SourceSet; | import org.gradle.api.tasks.SourceSet; | |||
import org.gradle.api.tasks.SourceSetContainer; | import org.gradle.api.tasks.SourceSetContainer; | |||
import org.gradle.api.tasks.testing.Test; | import org.gradle.api.tasks.testing.Test; | |||
import org.gradle.language.base.plugins.LifecycleBasePlugin; | import org.gradle.language.base.plugins.LifecycleBasePlugin; | |||
import org.gradle.plugins.ide.eclipse.EclipsePlugin; | import org.gradle.plugins.ide.eclipse.EclipsePlugin; | |||
import org.gradle.plugins.ide.eclipse.model.EclipseModel; | import org.gradle.plugins.ide.eclipse.model.EclipseModel; | |||
/** | /** | |||
* A {@link Plugin} to configure integration testing support in a {@link Project }. | * A {@link Plugin} to configure integration testing support in a {@link Project }. | |||
* | * | |||
skipping to change at line 64 | skipping to change at line 64 | |||
Test intTest = createTestTask(project, intTestSourceSet); | Test intTest = createTestTask(project, intTestSourceSet); | |||
project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME) .dependsOn(intTest); | project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME) .dependsOn(intTest); | |||
project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin ) -> { | project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin ) -> { | |||
EclipseModel eclipse = project.getExtensions().getByType( EclipseModel.class); | EclipseModel eclipse = project.getExtensions().getByType( EclipseModel.class); | |||
eclipse.classpath((classpath) -> classpath.getPlusConfigu rations().add( | eclipse.classpath((classpath) -> classpath.getPlusConfigu rations().add( | |||
project.getConfigurations().getByName(int TestSourceSet.getRuntimeClasspathConfigurationName()))); | project.getConfigurations().getByName(int TestSourceSet.getRuntimeClasspathConfigurationName()))); | |||
}); | }); | |||
} | } | |||
private SourceSet createSourceSet(Project project) { | private SourceSet createSourceSet(Project project) { | |||
SourceSetContainer sourceSets = project.getConvention().getPlugin (JavaPluginConvention.class).getSourceSets(); | SourceSetContainer sourceSets = project.getExtensions().getByType (JavaPluginExtension.class).getSourceSets(); | |||
SourceSet intTestSourceSet = sourceSets.create(INT_TEST_SOURCE_SE T_NAME); | SourceSet intTestSourceSet = sourceSets.create(INT_TEST_SOURCE_SE T_NAME); | |||
SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_N AME); | SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_N AME); | |||
intTestSourceSet.setCompileClasspath(intTestSourceSet.getCompileC lasspath().plus(main.getOutput())); | intTestSourceSet.setCompileClasspath(intTestSourceSet.getCompileC lasspath().plus(main.getOutput())); | |||
intTestSourceSet.setRuntimeClasspath(intTestSourceSet.getRuntimeC lasspath().plus(main.getOutput())); | intTestSourceSet.setRuntimeClasspath(intTestSourceSet.getRuntimeC lasspath().plus(main.getOutput())); | |||
return intTestSourceSet; | return intTestSourceSet; | |||
} | } | |||
private Test createTestTask(Project project, SourceSet intTestSourceSet) { | private Test createTestTask(Project project, SourceSet intTestSourceSet) { | |||
Test intTest = project.getTasks().create(INT_TEST_TASK_NAME, Test .class); | Test intTest = project.getTasks().create(INT_TEST_TASK_NAME, Test .class); | |||
intTest.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP); | intTest.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP); | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |