Search in sources :

Example 1 with Upload

use of org.gradle.api.tasks.Upload in project gradle by gradle.

the class UploadRule method createUploadTask.

private Upload createUploadTask(String name, final Configuration configuration, final Project project) {
    Upload upload = project.getTasks().create(name, Upload.class);
    upload.setDescription("Uploads all artifacts belonging to " + configuration);
    upload.setGroup(BasePlugin.UPLOAD_GROUP);
    upload.setConfiguration(configuration);
    upload.setUploadDescriptor(true);
    upload.getConventionMapping().map("descriptorDestination", new Callable<File>() {

        public File call() throws Exception {
            return new File(project.getBuildDir(), "ivy.xml");
        }
    });
    return upload;
}
Also used : Upload(org.gradle.api.tasks.Upload) File(java.io.File)

Example 2 with Upload

use of org.gradle.api.tasks.Upload in project gradle by gradle.

the class MavenPlugin method configureInstall.

private void configureInstall(Project project) {
    Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class);
    Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION);
    installUpload.setConfiguration(configuration);
    MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class);
    repositories.mavenInstaller();
    installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository.");
}
Also used : DefaultMavenRepositoryHandlerConvention(org.gradle.api.publication.maven.internal.DefaultMavenRepositoryHandlerConvention) Configuration(org.gradle.api.artifacts.Configuration) DslObject(org.gradle.api.internal.plugins.DslObject) Upload(org.gradle.api.tasks.Upload)

Example 3 with Upload

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

the class TaskHelperConfigurations method setDefaultMavenDescriptor.

protected void setDefaultMavenDescriptor() {
    // Flag to publish the Maven POM, but no pom file inputted, activate default Maven "install" task.
    // if the project doesn't have the maven install task, warn
    Project project = getProject();
    TaskContainer tasks = project.getTasks();
    Upload installTask = tasks.withType(Upload.class).findByName("install");
    if (installTask == null) {
        log.warn("Cannot publish pom for project '{}' since it does not contain the Maven " + "plugin install task and task '{}' does not specify a custom pom path.", new Object[] { project.getPath(), getPath() });
        artifactoryTask.mavenDescriptor = null;
    } else {
        artifactoryTask.mavenDescriptor = new File(project.getConvention().getPlugin(MavenPluginConvention.class).getMavenPomDir(), "pom-default.xml");
        dependsOn(installTask);
    }
}
Also used : Project(org.gradle.api.Project) TaskContainer(org.gradle.api.tasks.TaskContainer) MavenPluginConvention(org.gradle.api.plugins.MavenPluginConvention) Upload(org.gradle.api.tasks.Upload) File(java.io.File)

Example 4 with Upload

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

the class TaskHelperConfigurations method setDefaultIvyDescriptor.

protected void setDefaultIvyDescriptor() {
    Project project = getProject();
    TaskContainer tasks = project.getTasks();
    Configuration archiveConfig = project.getConfigurations().findByName(Dependency.ARCHIVES_CONFIGURATION);
    if (archiveConfig == null) {
        log.warn("Cannot publish Ivy descriptor if ivyDescriptor not set in task '{}' " + "and no '{}' configuration exists in project '{}'.", Dependency.ARCHIVES_CONFIGURATION, project.getPath());
    } else {
        // Flag to publish the Ivy XML file, but no ivy descriptor file inputted, activate default upload${configuration}.
        // ATTENTION: Tasks not part of the execution graph have withType(Upload.class) false ?!? Need to check for type our self.
        Task candidateUploadTask = tasks.findByName(archiveConfig.getUploadTaskName());
        if (candidateUploadTask == null) {
            log.warn("Cannot publish Ivy descriptor if ivyDescriptor not set in task '{}' " + "and task '{}' does not exist." + "\nAdding \"apply plugin: 'java'\" or any other plugin extending the 'base' plugin" + "will solve this issue.", new Object[] { getPath(), archiveConfig.getUploadTaskName() });
        } else {
            if (!(candidateUploadTask instanceof Upload)) {
                log.warn("Cannot publish Ivy descriptor if ivyDescriptor not set in task '{}' " + "and task '{}' is not an Upload task." + "\nYou'll need to set publishIvy=false or provide a path to the ivy file to " + "publish to solve this issue.", new Object[] { getPath(), archiveConfig.getUploadTaskName() });
            } else {
                Upload uploadTask = (Upload) candidateUploadTask;
                if (!uploadTask.isUploadDescriptor()) {
                    log.info("Forcing task '{}' to upload its Ivy descriptor (uploadDescriptor was false).", uploadTask.getPath());
                    uploadTask.setUploadDescriptor(true);
                }
                artifactoryTask.ivyDescriptor = uploadTask.getDescriptorDestination();
                dependsOn(candidateUploadTask);
            }
        }
    }
}
Also used : Project(org.gradle.api.Project) ArtifactoryTask(org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask) Task(org.gradle.api.Task) TaskContainer(org.gradle.api.tasks.TaskContainer) Configuration(org.gradle.api.artifacts.Configuration) ArtifactoryClientConfiguration(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration) Upload(org.gradle.api.tasks.Upload)

Aggregations

Upload (org.gradle.api.tasks.Upload)4 File (java.io.File)2 Project (org.gradle.api.Project)2 Configuration (org.gradle.api.artifacts.Configuration)2 TaskContainer (org.gradle.api.tasks.TaskContainer)2 Task (org.gradle.api.Task)1 DslObject (org.gradle.api.internal.plugins.DslObject)1 MavenPluginConvention (org.gradle.api.plugins.MavenPluginConvention)1 DefaultMavenRepositoryHandlerConvention (org.gradle.api.publication.maven.internal.DefaultMavenRepositoryHandlerConvention)1 ArtifactoryClientConfiguration (org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration)1 ArtifactoryTask (org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask)1