mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-04 09:42:29 +00:00
Add Gradle Lock Plugin
Issue gh-7788
This commit is contained in:
parent
06d7443946
commit
1bb1e74a9d
@ -11,6 +11,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply plugin: 'io.spring.nohttp'
|
apply plugin: 'io.spring.nohttp'
|
||||||
|
apply plugin: 'locks'
|
||||||
apply plugin: 'io.spring.convention.root'
|
apply plugin: 'io.spring.convention.root'
|
||||||
|
|
||||||
group = 'org.springframework.security'
|
group = 'org.springframework.security'
|
||||||
|
@ -10,6 +10,10 @@ gradlePlugin {
|
|||||||
id = "trang"
|
id = "trang"
|
||||||
implementationClass = "trang.TrangPlugin"
|
implementationClass = "trang.TrangPlugin"
|
||||||
}
|
}
|
||||||
|
locks {
|
||||||
|
id = "locks"
|
||||||
|
implementationClass = "lock.GlobalLockPlugin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
buildSrc/src/main/java/lock/GlobalLockPlugin.java
Normal file
16
buildSrc/src/main/java/lock/GlobalLockPlugin.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package lock;
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rob Winch
|
||||||
|
*/
|
||||||
|
public class GlobalLockPlugin implements Plugin<Project> {
|
||||||
|
@Override
|
||||||
|
public void apply(Project project) {
|
||||||
|
project.getTasks().register("writeLocks", GlobalLockTask.class, writeAll -> {
|
||||||
|
writeAll.setDescription("Writes the locks for all projects");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
40
buildSrc/src/main/java/lock/GlobalLockTask.java
Normal file
40
buildSrc/src/main/java/lock/GlobalLockTask.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package lock;
|
||||||
|
|
||||||
|
import org.gradle.api.Action;
|
||||||
|
import org.gradle.api.DefaultTask;
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.artifacts.Configuration;
|
||||||
|
import org.gradle.api.tasks.TaskAction;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rob Winch
|
||||||
|
*/
|
||||||
|
public class GlobalLockTask extends DefaultTask {
|
||||||
|
@TaskAction
|
||||||
|
public void lock() {
|
||||||
|
Project taskProject = getProject();
|
||||||
|
if (!taskProject.getGradle().getStartParameter().isWriteDependencyLocks()) {
|
||||||
|
throw new IllegalStateException("You just specify --write-locks argument");
|
||||||
|
}
|
||||||
|
writeLocksFor(taskProject);
|
||||||
|
taskProject.getSubprojects().forEach(new Consumer<Project>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Project subproject) {
|
||||||
|
writeLocksFor(subproject);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeLocksFor(Project project) {
|
||||||
|
project.getConfigurations().configureEach(new Action<Configuration>() {
|
||||||
|
@Override
|
||||||
|
public void execute(Configuration configuration) {
|
||||||
|
if (configuration.isCanBeResolved()) {
|
||||||
|
configuration.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -117,3 +117,7 @@ dependencies {
|
|||||||
management "org.thymeleaf:thymeleaf-spring5:3.0.11.RELEASE"
|
management "org.thymeleaf:thymeleaf-spring5:3.0.11.RELEASE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencyLocking {
|
||||||
|
lockAllConfigurations()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user