Skip to content

Commit

Permalink
update gradle spring version (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
HzjNeverStop authored Apr 22, 2022
1 parent 66d872a commit 9e6240d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ repositories {
dependencies {
implementation localGroovy()
implementation gradleApi()
implementation 'org.springframework.boot:spring-boot-gradle-plugin:2.3.9.RELEASE'
implementation 'org.springframework.boot:spring-boot-loader-tools:2.3.9.RELEASE'
implementation 'org.springframework.boot:spring-boot-gradle-plugin:2.4.13'
implementation 'org.springframework.boot:spring-boot-loader-tools:2.4.13'
implementation 'io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE'
implementation "org.apache.commons:commons-compress:1.19"
implementation "org.springframework:spring-core:5.2.13.RELEASE"
implementation "org.springframework:spring-core:5.3.18"
testImplementation 'junit:junit:4.13.1'
testImplementation gradleTestKit()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-gradle-plugin</artifactId>
<version>2.3.9.RELEASE</version>
<version>2.4.13</version>
</dependency>
<dependency>
<groupId>io.spring.gradle</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,25 @@
*/
package org.springframework.boot.gradle.plugin;

import com.alipay.sofa.boot.gradle.plugin.Marker;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.util.GradleVersion;
import org.springframework.boot.gradle.dsl.SpringBootExtension;

import java.io.File;
import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.jar.Attributes;
import java.util.jar.JarFile;

import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ResolvableDependencies;
import org.gradle.util.GradleVersion;
import org.springframework.boot.gradle.dsl.SpringBootExtension;

import com.alipay.sofa.boot.gradle.plugin.Marker;

/**
* Gradle plugin for SOFA Boot. (Origin from {@link SpringBootPlugin})
*
Expand Down Expand Up @@ -70,7 +69,6 @@ public void apply(Project project) {
createExtension(project);
Configuration bootArchives = createBootArchivesConfiguration(project);
registerPluginActions(project, bootArchives);
unregisterUnresolvedDependenciesAnalyzer(project);
}

private void verifyGradleVersion() {
Expand All @@ -92,6 +90,7 @@ private Configuration createBootArchivesConfiguration(Project project) {
Configuration bootArchives = project.getConfigurations().create(
BOOT_ARCHIVES_CONFIGURATION_NAME);
bootArchives.setDescription("Configuration for Spring Boot archive artifacts.");
bootArchives.setCanBeResolved(false);
return bootArchives;
}

Expand All @@ -105,29 +104,18 @@ private void registerPluginActions(Project project, Configuration bootArchives)
new SofaDependencyManagementPluginAction(), new ApplicationPluginAction(),
new KotlinPluginAction());
for (PluginApplicationAction action : actions) {
Class<? extends Plugin<? extends Project>> pluginClass = action
.getPluginClass();
if (pluginClass != null) {
project.getPlugins().withType(pluginClass,
(plugin) -> action.execute(project));
}
withPluginClassOfAction(action,
(pluginClass) -> project.getPlugins().withType(pluginClass, (plugin) -> action.execute(project)));
}
}

private void unregisterUnresolvedDependenciesAnalyzer(Project project) {
UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer();
project.getConfigurations().all((configuration) -> {
ResolvableDependencies incoming = configuration.getIncoming();
incoming.afterResolve((resolvableDependencies) -> {
if (incoming.equals(resolvableDependencies)) {
unresolvedDependenciesAnalyzer.analyze(configuration
.getResolvedConfiguration().getLenientConfiguration()
.getUnresolvedModuleDependencies());
}
});
});
project.getGradle().buildFinished(
(buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project));
private void withPluginClassOfAction(PluginApplicationAction action,
Consumer<Class<? extends Plugin<? extends Project>>> consumer) {
try {
consumer.accept(action.getPluginClass());
} catch (Throwable ex) {
// Plugin class unavailable. Continue.
}
}

// This method always returns null when executing gradle test
Expand Down

0 comments on commit 9e6240d

Please sign in to comment.