Search in sources :

Example 56 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class CreateGitHubReleaseTask method readReleaseNotes.

private String readReleaseNotes() {
    Project project = getProject();
    File inputFile = project.file(Paths.get(project.getBuildDir().getPath(), GitHubChangelogPlugin.RELEASE_NOTES_PATH));
    try {
        return Files.readString(inputFile.toPath());
    } catch (IOException ex) {
        throw new RuntimeException("Unable to read release notes from " + inputFile, ex);
    }
}
Also used : Project(org.gradle.api.Project) IOException(java.io.IOException) File(java.io.File)

Example 57 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class GlobalLockTask method lock.

@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);
        }
    });
}
Also used : Project(org.gradle.api.Project) TaskAction(org.gradle.api.tasks.TaskAction)

Example 58 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class PublishAllJavaComponentsPlugin method apply.

@Override
public void apply(Project project) {
    project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> {
        PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
        publishing.getPublications().create("mavenJava", MavenPublication.class, new Action<MavenPublication>() {

            @Override
            public void execute(MavenPublication maven) {
                project.getPlugins().withType(JavaPlugin.class, (plugin) -> {
                    maven.from(project.getComponents().getByName("java"));
                });
                project.getPlugins().withType(JavaPlatformPlugin.class, (plugin) -> {
                    maven.from(project.getComponents().getByName("javaPlatform"));
                });
            }
        });
    });
}
Also used : PublishingExtension(org.gradle.api.publish.PublishingExtension) Action(org.gradle.api.Action) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin) Project(org.gradle.api.Project) VariantVersionMappingStrategy(org.gradle.api.publish.VariantVersionMappingStrategy) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) JavaPlugin(org.gradle.api.plugins.JavaPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) Plugin(org.gradle.api.Plugin) VersionMappingStrategy(org.gradle.api.publish.VersionMappingStrategy) MavenPublishPlugin(org.gradle.api.publish.maven.plugins.MavenPublishPlugin) MavenPublication(org.gradle.api.publish.maven.MavenPublication) JavaPlugin(org.gradle.api.plugins.JavaPlugin) PublishingExtension(org.gradle.api.publish.PublishingExtension) JavaPlatformPlugin(org.gradle.api.plugins.JavaPlatformPlugin)

Example 59 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class S101Configurer method hspTemplateValues.

private Map<String, Object> hspTemplateValues(String version, File configurationDirectory) {
    Map<String, Object> values = new LinkedHashMap<>();
    values.put("version", version);
    values.put("patchVersion", version.split("\\.")[2]);
    values.put("relativeTo", "const(THIS_FILE)/" + configurationDirectory.toPath().relativize(this.project.getProjectDir().toPath()));
    List<Map<String, Object>> entries = new ArrayList<>();
    Set<Project> projects = this.project.getAllprojects();
    for (Project p : projects) {
        SourceSetContainer sourceSets = (SourceSetContainer) p.getExtensions().findByName("sourceSets");
        if (sourceSets == null) {
            continue;
        }
        for (SourceSet source : sourceSets) {
            Set<File> classDirs = source.getOutput().getClassesDirs().getFiles();
            for (File directory : classDirs) {
                Map<String, Object> entry = new HashMap<>();
                entry.put("path", this.project.getProjectDir().toPath().relativize(directory.toPath()));
                entry.put("module", p.getName());
                entries.add(entry);
            }
        }
    }
    values.put("entries", entries);
    return values;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) LinkedHashMap(java.util.LinkedHashMap) Project(org.gradle.api.Project) SourceSet(org.gradle.api.tasks.SourceSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File)

Example 60 with Project

use of org.gradle.api.Project in project spring-security by spring-projects.

the class S101Plugin method configure.

private void configure(JavaExec exec) {
    exec.setDescription("Runs Structure101 headless analysis, installing and configuring if necessary");
    exec.dependsOn("check");
    Project project = exec.getProject();
    S101PluginExtension extension = project.getExtensions().getByType(S101PluginExtension.class);
    exec.workingDir(extension.getInstallationDirectory()).classpath(new File(extension.getInstallationDirectory().get(), "structure101-java-build.jar")).args(new File(new File(project.getBuildDir(), "s101"), "config.xml")).systemProperty("s101.label", computeLabel(extension).get()).doFirst((task) -> {
        installAndConfigureIfNeeded(project);
        copyConfigurationToBuildDirectory(extension, project);
    }).doLast((task) -> {
        copyResultsBackToConfigurationDirectory(extension, project);
    });
}
Also used : Files(java.nio.file.Files) Project(org.gradle.api.Project) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) StandardCopyOption(java.nio.file.StandardCopyOption) ByteArrayInputStream(java.io.ByteArrayInputStream) Property(org.gradle.api.provider.Property) JavaExec(org.gradle.api.tasks.JavaExec) Path(java.nio.file.Path) Plugin(org.gradle.api.Plugin) InputStream(java.io.InputStream) Project(org.gradle.api.Project) File(java.io.File)

Aggregations

Project (org.gradle.api.Project)269 File (java.io.File)98 Task (org.gradle.api.Task)71 Plugin (org.gradle.api.Plugin)69 Configuration (org.gradle.api.artifacts.Configuration)53 List (java.util.List)40 ArrayList (java.util.ArrayList)39 SourceSet (org.gradle.api.tasks.SourceSet)38 TaskProvider (org.gradle.api.tasks.TaskProvider)38 IOException (java.io.IOException)35 Map (java.util.Map)35 Action (org.gradle.api.Action)34 Set (java.util.Set)32 JavaPlugin (org.gradle.api.plugins.JavaPlugin)31 FileCollection (org.gradle.api.file.FileCollection)30 Provider (org.gradle.api.provider.Provider)27 HashMap (java.util.HashMap)26 Collectors (java.util.stream.Collectors)26 ObjectFactory (org.gradle.api.model.ObjectFactory)25 Collections (java.util.Collections)24