Java 类org.gradle.api.publish.plugins.PublishingPlugin 实例源码

项目:Reer    文件:MavenPublishPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().apply(PublishingPlugin.class);

    final TaskContainer tasks = project.getTasks();
    final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
    publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache.");
    publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });
}
项目:Reer    文件:MavenPublishPlugin.java   
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(ModelMap<Task> tasks, PublishingExtension extension, @Path("buildDir") File buildDir) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();
    Task publishLifecycleTask = tasks.get(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
    Task publishLocalLifecycleTask = tasks.get(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);

    for (final MavenPublicationInternal publication : publications.withType(MavenPublicationInternal.class)) {
        String publicationName = publication.getName();

        createGeneratePomTask(tasks, publication, publicationName, buildDir);
        createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName);
    }
}
项目:Reer    文件:MavenPublishPlugin.java   
private void createPublishTasksForEachMavenRepo(ModelMap<Task> tasks, PublishingExtension extension, final Task publishLifecycleTask, final MavenPublicationInternal publication,
                                                final String publicationName) {
    for (final MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) {
        final String repositoryName = repository.getName();

        String publishTaskName = "publish" + capitalize(publicationName) + "PublicationTo" + capitalize(repositoryName) + "Repository";

        tasks.create(publishTaskName, PublishToMavenRepository.class, new Action<PublishToMavenRepository>() {
            public void execute(PublishToMavenRepository publishTask) {
                publishTask.setPublication(publication);
                publishTask.setRepository(repository);
                publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                publishTask.setDescription("Publishes Maven publication '" + publicationName + "' to Maven repository '" + repositoryName + "'.");

            }
        });
        publishLifecycleTask.dependsOn(publishTaskName);
    }
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
public void apply(final Project project) {
    project.getPlugins().apply(PublishingPlugin.class);

    final TaskContainer tasks = project.getTasks();
    final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
    publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache.");
    publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
private void createPublishTasksForEachMavenRepo(CollectionBuilder<Task> tasks, PublishingExtension extension, final Task publishLifecycleTask, final MavenPublicationInternal publication,
                                                final String publicationName) {
    for (final MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) {
        final String repositoryName = repository.getName();

        String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

        tasks.create(publishTaskName, PublishToMavenRepository.class, new Action<PublishToMavenRepository>() {
            public void execute(PublishToMavenRepository publishTask) {
                publishTask.setPublication(publication);
                publishTask.setRepository(repository);
                publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                publishTask.setDescription(String.format("Publishes Maven publication '%s' to Maven repository '%s'.", publicationName, repositoryName));

                //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step
                publishLifecycleTask.dependsOn(publishTask);
            }
        });
    }
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
private void createGeneratePomTask(CollectionBuilder<Task> tasks, final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() {
        public void execute(final GenerateMavenPom generatePomTask) {
            generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
            generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            generatePomTask.setPom(publication.getPom());

            ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
            descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(generatePomTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
                }
            });

            // Wire the generated pom into the publication.
            publication.setPomFile(generatePomTask.getOutputs().getFiles());
        }
    });
}
项目:Pushjet-Android    文件:MavenPublishTaskModelRule.java   
private void createGeneratePomTask(final MavenPublicationInternal publication, String publicationName) {
    String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
    GenerateMavenPom generatePomTask = project.getTasks().create(descriptorTaskName, GenerateMavenPom.class);
    generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
    generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    generatePomTask.setPom(publication.getPom());

    ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
    descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return new File(project.getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
        }
    });

    // Wire the generated pom into the publication.
    publication.setPomFile(generatePomTask.getOutputs().getFiles());
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
public void apply(final Project project) {
    project.getPlugins().apply(PublishingPlugin.class);

    final TaskContainer tasks = project.getTasks();
    final Task publishLifecycleTask = tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME);
    final Task publishLocalLifecycleTask = tasks.create(PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
    publishLocalLifecycleTask.setDescription("Publishes all Maven publications produced by this project to the local Maven cache.");
    publishLocalLifecycleTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(MavenPublication.class, new MavenPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });

    modelRules.rule(new MavenPublishTaskModelRule(project, publishLifecycleTask, publishLocalLifecycleTask));
}
项目:Reer    文件:MavenPublishPlugin.java   
private void createLocalInstallTask(ModelMap<Task> tasks, final Task publishLocalLifecycleTask, final MavenPublicationInternal publication, final String publicationName) {
    final String installTaskName = "publish" + capitalize(publicationName) + "PublicationToMavenLocal";

    tasks.create(installTaskName, PublishToMavenLocal.class, new Action<PublishToMavenLocal>() {
        public void execute(PublishToMavenLocal publishLocalTask) {
            publishLocalTask.setPublication(publication);
            publishLocalTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishLocalTask.setDescription("Publishes Maven publication '" + publicationName + "' to the local Maven repository.");
        }
    });
    publishLocalLifecycleTask.dependsOn(installTaskName);
}
项目:Reer    文件:MavenPublishPlugin.java   
private void createGeneratePomTask(ModelMap<Task> tasks, final MavenPublicationInternal publication, final String publicationName, final File buildDir) {
    String descriptorTaskName = "generatePomFileFor" + capitalize(publicationName) + "Publication";
    tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() {
        public void execute(final GenerateMavenPom generatePomTask) {
            generatePomTask.setDescription("Generates the Maven POM file for publication '" + publicationName + "'.");
            generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            generatePomTask.setPom(publication.getPom());
            generatePomTask.setDestination(new File(buildDir, "publications/" + publication.getName() + "/pom-default.xml"));
        }
    });
    // Wire the generated pom into the publication.
    publication.setPomFile(tasks.get(descriptorTaskName).getOutputs().getFiles());
}
项目:Reer    文件:IvyPublishPlugin.java   
public void apply(final Project project) {
    project.getPluginManager().apply(PublishingPlugin.class);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(IvyPublication.class, new IvyPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });
}
项目:Reer    文件:IvyPublishPlugin.java   
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void createTasks(ModelMap<Task> tasks, PublishingExtension publishingExtension, @Path("buildDir") final File buildDir) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = "generateDescriptorFileFor" + capitalize(publicationName) + "Publication";

        tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() {
            public void execute(final GenerateIvyDescriptor descriptorTask) {
                descriptorTask.setDescription("Generates the Ivy Module Descriptor XML file for publication '" + publicationName + "'.");
                descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                descriptorTask.setDescriptor(publication.getDescriptor());
                descriptorTask.setDestination(new File(buildDir, "publications/" + publicationName + "/ivy.xml"));
            }
        });
        publication.setDescriptorFile(tasks.get(descriptorTaskName).getOutputs().getFiles());

        for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = "publish" + capitalize(publicationName) + "PublicationTo" + capitalize(repositoryName) + "Repository";

            tasks.create(publishTaskName, PublishToIvyRepository.class, new Action<PublishToIvyRepository>() {
                public void execute(PublishToIvyRepository publishTask) {
                    publishTask.setPublication(publication);
                    publishTask.setRepository(repository);
                    publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                    publishTask.setDescription("Publishes Ivy publication '" + publicationName + "' to Ivy repository '" + repositoryName + "'.");
                }
            });
            tasks.get(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTaskName);
        }
    }
}
项目:gradle-project-config    文件:MavenConfigPlugin.java   
/**
 * Create the install task from the Maven configuration
 *
 * @param tasks Task model to create task in
 */
@Mutate
public void createInstallTask(ModelMap<Task> tasks) {
    tasks.create("install", Task.class, t -> {
        t.setDescription("Install to local repository, convenience alias for 'publishToMavenLocal'");
        t.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        t.dependsOn(MavenPublishPlugin.PUBLISH_LOCAL_LIFECYCLE_TASK_NAME);
    });
}
项目:Pushjet-Android    文件:MavenPublishPlugin.java   
private void createLocalInstallTask(CollectionBuilder<Task> tasks, final Task publishLocalLifecycleTask, final MavenPublicationInternal publication, final String publicationName) {
    final String installTaskName = String.format("publish%sPublicationToMavenLocal", capitalize(publicationName));

    tasks.create(installTaskName, PublishToMavenLocal.class, new Action<PublishToMavenLocal>() {
        public void execute(PublishToMavenLocal publishLocalTask) {
            publishLocalTask.setPublication(publication);
            publishLocalTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishLocalTask.setDescription(String.format("Publishes Maven publication '%s' to the local Maven repository.", publicationName));

            //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step
            publishLocalLifecycleTask.dependsOn(installTaskName);
        }
    });
}
项目:Pushjet-Android    文件:IvyPublishPlugin.java   
public void apply(final Project project) {
    project.getPlugins().apply(PublishingPlugin.class);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(IvyPublication.class, new IvyPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });
}
项目:Pushjet-Android    文件:MavenPublishTaskModelRule.java   
private void createPublishTasksForEachMavenRepo(TaskContainer tasks, PublishingExtension extension, MavenPublicationInternal publication, String publicationName) {
    for (MavenArtifactRepository repository : extension.getRepositories().withType(MavenArtifactRepository.class)) {
        String repositoryName = repository.getName();

        String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

        PublishToMavenRepository publishTask = tasks.create(publishTaskName, PublishToMavenRepository.class);
        publishTask.setPublication(publication);
        publishTask.setRepository(repository);
        publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        publishTask.setDescription(String.format("Publishes Maven publication '%s' to Maven repository '%s'.", publicationName, repositoryName));

        publishLifecycleTask.dependsOn(publishTask);
    }
}
项目:Pushjet-Android    文件:MavenPublishTaskModelRule.java   
private void createLocalInstallTask(TaskContainer tasks, MavenPublicationInternal publication, String publicationName) {
    String installTaskName = String.format("publish%sPublicationToMavenLocal", capitalize(publicationName));

    PublishToMavenLocal publishLocalTask = tasks.create(installTaskName, PublishToMavenLocal.class);
    publishLocalTask.setPublication(publication);
    publishLocalTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
    publishLocalTask.setDescription(String.format("Publishes Maven publication '%s' to the local Maven repository.", publicationName));

    publishLocalLifecycleTask.dependsOn(installTaskName);
}
项目:Pushjet-Android    文件:IvyPublicationTasksModelRule.java   
public void createTasks(TaskContainer tasks, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        GenerateIvyDescriptor descriptorTask = tasks.create(descriptorTaskName, GenerateIvyDescriptor.class);
        descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
        descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
        descriptorTask.setDescriptor(publication.getDescriptor());

        ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
        descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
            public Object call() throws Exception {
                return new File(project.getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
            }
        });

        publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());

        for (IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            PublishToIvyRepository publishTask = tasks.create(publishTaskName, PublishToIvyRepository.class);
            publishTask.setPublication(publication);
            publishTask.setRepository(repository);
            publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
            publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

            tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME).dependsOn(publishTask);
        }
    }
}
项目:Pushjet-Android    文件:IvyPublishPlugin.java   
public void apply(final Project project) {
    project.getPlugins().apply(PublishingPlugin.class);

    // Can't move this to rules yet, because it has to happen before user deferred configurable actions
    project.getExtensions().configure(PublishingExtension.class, new Action<PublishingExtension>() {
        public void execute(PublishingExtension extension) {
            // Register factory for MavenPublication
            extension.getPublications().registerFactory(IvyPublication.class, new IvyPublicationFactory(dependencyMetaDataProvider, instantiator, fileResolver));
        }
    });

    modelRules.rule(new IvyPublicationTasksModelRule(project));
}
项目:checkstyle-addons    文件:GeneratePomFileTask.java   
public GeneratePomFileTask()
{
    super();
    setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);

    final Project project = getProject();
    buildUtil = new BuildUtil(project);

    final TaskInputs inputs = getInputs();
    inputs.property("groupId", project.getGroup());
    inputs.property("artifactId", project.getName());
    inputs.property("version", project.getVersion());
    inputs.property("name", buildUtil.getLongName());
    inputs.property("description", project.getDescription());
    inputs.property("url", buildUtil.getExtraPropertyValue(ExtProp.Website));
    inputs.property("authorName", buildUtil.getExtraPropertyValue(ExtProp.AuthorName));
    inputs.property("orgName", buildUtil.getExtraPropertyValue(ExtProp.OrgName));
    inputs.property("orgUrl", buildUtil.getExtraPropertyValue(ExtProp.OrgUrl));
    inputs.property("github", buildUtil.getExtraPropertyValue(ExtProp.Github));

    getOutputs().file(pomFile);

    doLast(new Closure<Void>(this)
    {
        @Override
        @SuppressWarnings({"ResultOfMethodCallIgnored", "MethodDoesntCallSuperMethod"})
        public Void call()
        {
            pomFile.getParentFile().mkdirs();
            PomXml pomXml = createPom();
            try {
                writePomXml(pomXml);
            }
            catch (JAXBException e) {
                throw new GradleException("error creating pom", e);
            }
            return null;
        }
    });
}
项目:Pushjet-Android    文件:IvyPublishPlugin.java   
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void createTasks(CollectionBuilder<Task> tasks, final @Path("tasks.publish") Task publishLifecycleTask, PublishingExtension publishingExtension) {
    PublicationContainer publications = publishingExtension.getPublications();
    RepositoryHandler repositories = publishingExtension.getRepositories();

    for (final IvyPublicationInternal publication : publications.withType(IvyPublicationInternal.class)) {

        final String publicationName = publication.getName();
        final String descriptorTaskName = String.format("generateDescriptorFileFor%sPublication", capitalize(publicationName));

        tasks.create(descriptorTaskName, GenerateIvyDescriptor.class, new Action<GenerateIvyDescriptor>() {
            public void execute(final GenerateIvyDescriptor descriptorTask) {
                descriptorTask.setDescription(String.format("Generates the Ivy Module Descriptor XML file for publication '%s'.", publication.getName()));
                descriptorTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                descriptorTask.setDescriptor(publication.getDescriptor());

                ConventionMapping descriptorTaskConventionMapping = new DslObject(descriptorTask).getConventionMapping();
                descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
                    public Object call() throws Exception {
                        return new File(descriptorTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/ivy.xml");
                    }
                });

                publication.setDescriptorFile(descriptorTask.getOutputs().getFiles());
            }
        });

        for (final IvyArtifactRepository repository : repositories.withType(IvyArtifactRepository.class)) {
            final String repositoryName = repository.getName();
            final String publishTaskName = String.format("publish%sPublicationTo%sRepository", capitalize(publicationName), capitalize(repositoryName));

            tasks.create(publishTaskName, PublishToIvyRepository.class, new Action<PublishToIvyRepository>() {
                public void execute(PublishToIvyRepository publishTask) {
                    publishTask.setPublication(publication);
                    publishTask.setRepository(repository);
                    publishTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
                    publishTask.setDescription(String.format("Publishes Ivy publication '%s' to Ivy repository '%s'.", publicationName, repositoryName));

                    //Because dynamic rules are not yet implemented we have to violate input immutability here as an interim step
                    publishLifecycleTask.dependsOn(publishTask);
                }
            });
        }
    }
}