Search in sources :

Example 51 with Project

use of org.gradle.api.Project in project build-info by JFrogDev.

the class ArtifactoryTask method projectEvaluated.

public void projectEvaluated() {
    Project project = getProject();
    if (isSkip()) {
        log.debug("artifactoryPublish task '{}' skipped for project '{}'.", this.getPath(), project.getName());
    } else {
        ArtifactoryPluginConvention convention = ArtifactoryPluginUtil.getPublisherConvention(project);
        if (convention != null) {
            ArtifactoryClientConfiguration acc = convention.getClientConfig();
            artifactSpecs.clear();
            artifactSpecs.addAll(acc.publisher.getArtifactSpecs());
            // Configure the task using the "defaults" closure (delegate to the task)
            PublisherConfig config = convention.getPublisherConfig();
            if (config != null) {
                Closure defaultsClosure = config.getDefaultsClosure();
                ConfigureUtil.configure(defaultsClosure, this);
            }
        }
        Task deployTask = project.getRootProject().getTasks().findByName(DEPLOY_TASK_NAME);
        if (deployTask == null) {
            throw new IllegalStateException(String.format("Could not find %s in the root project", DEPLOY_TASK_NAME));
        }
        finalizedBy(deployTask);
        // Depend on buildInfo task in sub-projects
        for (Project sub : project.getSubprojects()) {
            Task subArtifactoryTask = sub.getTasks().findByName(ARTIFACTORY_PUBLISH_TASK_NAME);
            if (subArtifactoryTask != null) {
                dependsOn(subArtifactoryTask);
            }
        }
        checkDependsOnArtifactsToPublish();
    }
}
Also used : ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) Project(org.gradle.api.Project) Task(org.gradle.api.Task) DefaultTask(org.gradle.api.DefaultTask) Closure(groovy.lang.Closure) ArtifactoryPluginConvention(org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention) PublisherConfig(org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig)

Example 52 with Project

use of org.gradle.api.Project in project build-info by JFrogDev.

the class ArtifactoryTask method properties.

public void properties(Closure closure) {
    Project project = getProject();
    PropertiesConfig propertiesConfig = new PropertiesConfig(project);
    ConfigureUtil.configure(closure, propertiesConfig);
    artifactSpecs.clear();
    artifactSpecs.addAll(propertiesConfig.getArtifactSpecs());
}
Also used : Project(org.gradle.api.Project) PropertiesConfig(org.jfrog.gradle.plugin.artifactory.dsl.PropertiesConfig)

Example 53 with Project

use of org.gradle.api.Project in project shipkit by mockito.

the class CloneGitRepositoryTaskFactory method createCloneTask.

/**
 * Creates an instance of CloneGitRepositoryTask for given {@param #consumerRepository} in the root project
 * or returns already existing one.
 */
public static CloneGitRepositoryTask createCloneTask(final Project project, final String gitHubUrl, final String consumerRepository) {
    String taskName = "clone" + repositoryNameToCapitalizedCamelCase(consumerRepository);
    Project taskProject = project.getRootProject();
    CloneGitRepositoryTask alreadyExistingTask = (CloneGitRepositoryTask) taskProject.getTasks().findByName(taskName);
    if (alreadyExistingTask != null) {
        return alreadyExistingTask;
    }
    return TaskMaker.task(taskProject, taskName, CloneGitRepositoryTask.class, new Action<CloneGitRepositoryTask>() {

        @Override
        public void execute(final CloneGitRepositoryTask task) {
            task.setDescription("Clones consumer repo " + consumerRepository + " into a temporary directory.");
            task.setRepositoryUrl(gitHubUrl + "/" + consumerRepository);
            task.setTargetDir(getConsumerRepoCloneDir(project, consumerRepository));
        }
    });
}
Also used : Project(org.gradle.api.Project) CloneGitRepositoryTask(org.shipkit.internal.gradle.git.tasks.CloneGitRepositoryTask)

Example 54 with Project

use of org.gradle.api.Project in project component-runtime by Talend.

the class TaCoKitPlugin method apply.

@Override
public void apply(final Project project) {
    // setup the global config
    project.getExtensions().add("talendComponentKit", TaCoKitExtension.class);
    // ensure we can find our dependencies
    project.afterEvaluate(actionProject -> actionProject.getRepositories().mavenCentral());
    // create the configuration for our task execution
    final Configuration configuration = project.getConfigurations().maybeCreate("talendComponentKit");
    configuration.getIncoming().beforeResolve(resolvableDependencies -> {
        TaCoKitExtension extension = TaCoKitExtension.class.cast(project.getExtensions().findByName("talendComponentKit"));
        if (extension == null) {
            extension = new TaCoKitExtension();
        }
        final DependencyHandler dependencyHandler = project.getDependencies();
        final DependencySet dependencies = configuration.getDependencies();
        dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-api:" + extension.getApiVersion()));
        dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-tools:" + extension.getSdkVersion()));
        dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-runtime-design-extension:" + extension.getSdkVersion()));
    });
    // create the web configuration for our web task
    final Configuration webConfiguration = project.getConfigurations().maybeCreate("talendComponentKitWeb");
    webConfiguration.getIncoming().beforeResolve(resolvableDependencies -> {
        TaCoKitExtension extension = TaCoKitExtension.class.cast(project.getExtensions().findByName("talendComponentKitWeb"));
        if (extension == null) {
            extension = new TaCoKitExtension();
        }
        final DependencyHandler dependencyHandler = project.getDependencies();
        final DependencySet dependencies = configuration.getDependencies();
        dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-tools-webapp:" + extension.getSdkVersion()));
    });
    // tasks
    final String group = "Talend Component Kit";
    // TALEND-INF/dependencies.txt
    project.task(new HashMap<String, Object>() {

        {
            put("type", DependenciesTask.class);
            put("group", group);
            put("description", "Creates the Talend Component Kit dependencies file used by the runtime to build the component classloader");
        }
    }, "talendComponentKitDependencies");
    project.afterEvaluate(p -> p.getTasksByName("compileJava", false).stream().findFirst().ifPresent(compileJava -> compileJava.setFinalizedBy(singleton("talendComponentKitDependencies"))));
    // validation
    project.task(new HashMap<String, Object>() {

        {
            put("type", ValidateTask.class);
            put("group", group);
            put("description", "Validates that the module components are respecting the component standards.");
        }
    }, "talendComponentKitValidation");
    project.afterEvaluate(p -> p.getTasksByName("classes", false).stream().findFirst().ifPresent(compileJava -> compileJava.setFinalizedBy(singleton("talendComponentKitValidation"))));
    // documentation
    project.task(new HashMap<String, Object>() {

        {
            put("type", DocumentationTask.class);
            put("group", group);
            put("description", "Generates an asciidoc file with the documentation of the components.");
        }
    }, "talendComponentKitDocumentation");
    project.afterEvaluate(p -> p.getTasksByName("classes", false).stream().findFirst().ifPresent(compileJava -> compileJava.setFinalizedBy(singleton("talendComponentKitDocumentation"))));
    // web
    project.task(new HashMap<String, Object>() {

        {
            put("type", WebTask.class);
            put("group", group);
            put("description", "Starts a web server allowing you to browse your components (requires the component to be installed before).");
        }
    }, "talendComponentKitWebServer");
    // car
    project.task(new HashMap<String, Object>() {

        {
            put("type", CarTask.class);
            put("group", group);
            put("description", "Creates a Component ARchive (.car) based on current project.");
        }
    }, "talendComponentKitComponentArchive");
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) Collections.singleton(java.util.Collections.singleton) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) Project(org.gradle.api.Project) HashMap(java.util.HashMap) DependencySet(org.gradle.api.artifacts.DependencySet) Plugin(org.gradle.api.Plugin) Configuration(org.gradle.api.artifacts.Configuration) DependencySet(org.gradle.api.artifacts.DependencySet) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler)

Example 55 with Project

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

the class CopyPropertiesPlugin method copyPropertyFromRootProjectTo.

private void copyPropertyFromRootProjectTo(String propertyName, Project project) {
    Project rootProject = project.getRootProject();
    Object property = rootProject.findProperty(propertyName);
    if (property != null) {
        project.setProperty(propertyName, property);
    }
}
Also used : Project(org.gradle.api.Project)

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