Java Code Examples for org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal

The following examples show how to use org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: pushfish-android   Author: PushFish   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
            }
        });
    }
}
 
Example #2
Source Project: pushfish-android   Author: PushFish   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
        }
    });
}
 
Example #3
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Inject
public PublishToMavenRepository(Factory<LoggingManagerInternal> loggingManagerFactory) {
    this.loggingManagerFactory = loggingManagerFactory;


    // Allow the publication to participate in incremental build
    getInputs().files(new Callable<FileCollection>() {
        public FileCollection call() throws Exception {
            MavenPublicationInternal publicationInternal = getPublicationInternal();
            return publicationInternal == null ? null : publicationInternal.getPublishableFiles();
        }
    });

    // Should repositories be able to participate in incremental?
    // At the least, they may be able to express themselves as output files
    // They *might* have input files and other dependencies as well though
    // Inputs: The credentials they need may be expressed in a file
    // Dependencies: Can't think of a case here
}
 
Example #4
Source Project: pushfish-android   Author: PushFish   File: MavenPublishTaskModelRule.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
}
 
Example #5
Source Project: Pushjet-Android   Author: Pushjet   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
            }
        });
    }
}
 
Example #6
Source Project: Pushjet-Android   Author: Pushjet   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
        }
    });
}
 
Example #7
Source Project: Pushjet-Android   Author: Pushjet   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Inject
public PublishToMavenRepository(Factory<LoggingManagerInternal> loggingManagerFactory) {
    this.loggingManagerFactory = loggingManagerFactory;


    // Allow the publication to participate in incremental build
    getInputs().files(new Callable<FileCollection>() {
        public FileCollection call() throws Exception {
            MavenPublicationInternal publicationInternal = getPublicationInternal();
            return publicationInternal == null ? null : publicationInternal.getPublishableFiles();
        }
    });

    // Should repositories be able to participate in incremental?
    // At the least, they may be able to express themselves as output files
    // They *might* have input files and other dependencies as well though
    // Inputs: The credentials they need may be expressed in a file
    // Dependencies: Can't think of a case here
}
 
Example #8
Source Project: Pushjet-Android   Author: Pushjet   File: MavenPublishTaskModelRule.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
}
 
Example #9
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenLocal.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            MavenPublisher antBackedPublisher = new AntTaskBackedMavenLocalPublisher(getLoggingManagerFactory(), getTemporaryDirFactory());
            MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher);
            MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
            validatingPublisher.publish(publication.asNormalisedPublication(), repository);
        }
    }.run();
}
 
Example #10
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public PublishToMavenRepository() {
    // Allow the publication to participate in incremental build
    getInputs().files(new Callable<FileCollection>() {
        public FileCollection call() throws Exception {
            MavenPublicationInternal publicationInternal = getPublicationInternal();
            return publicationInternal == null ? null : publicationInternal.getPublishableFiles();
        }
    });

    // Should repositories be able to participate in incremental?
    // At the least, they may be able to express themselves as output files
    // They *might* have input files and other dependencies as well though
    // Inputs: The credentials they need may be expressed in a file
    // Dependencies: Can't think of a case here
}
 
Example #11
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static MavenPublicationInternal toPublicationInternal(MavenPublication publication) {
    if (publication == null) {
        return null;
    } else if (publication instanceof MavenPublicationInternal) {
        return (MavenPublicationInternal) publication;
    } else {
        throw new InvalidUserDataException(
                String.format(
                        "publication objects must implement the '%s' interface, implementation '%s' does not",
                        MavenPublicationInternal.class.getName(),
                        publication.getClass().getName()
                )
        );
    }
}
 
Example #12
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    MavenPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    MavenArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #13
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            MavenPublisher antBackedPublisher = new AntTaskBackedMavenPublisher(getLoggingManagerFactory(), getTemporaryDirFactory());
            MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher);
            MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
            validatingPublisher.publish(publication.asNormalisedPublication(), repository);
        }
    }.run();
}
 
Example #14
Source Project: pushfish-android   Author: PushFish   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(CollectionBuilder<Task> tasks, @Path("tasks.publish") Task publishLifecycleTask, @Path("tasks.publishToMavenLocal") Task publishLocalLifecycleTask,
                                   PublishingExtension extension) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();

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

        createGeneratePomTask(tasks, publication, publicationName);
        createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName);
    }
}
 
Example #15
Source Project: pushfish-android   Author: PushFish   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
        }
    });
}
 
Example #16
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenLocal.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            MavenPublisher antBackedPublisher = new AntTaskBackedMavenLocalPublisher(getLoggingManagerFactory(), getTemporaryDirFactory());
            MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher);
            MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
            validatingPublisher.publish(publication.asNormalisedPublication(), repository);
        }
    }.run();
}
 
Example #17
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static MavenPublicationInternal toPublicationInternal(MavenPublication publication) {
    if (publication == null) {
        return null;
    } else if (publication instanceof MavenPublicationInternal) {
        return (MavenPublicationInternal) publication;
    } else {
        throw new InvalidUserDataException(
                String.format(
                        "publication objects must implement the '%s' interface, implementation '%s' does not",
                        MavenPublicationInternal.class.getName(),
                        publication.getClass().getName()
                )
        );
    }
}
 
Example #18
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    MavenPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    MavenArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #19
Source Project: pushfish-android   Author: PushFish   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            MavenPublisher antBackedPublisher = new AntTaskBackedMavenPublisher(loggingManagerFactory, getTemporaryDirFactory());
            MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher);
            MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
            validatingPublisher.publish(publication.asNormalisedPublication(), repository);
        }
    }.run();
}
 
Example #20
Source Project: pushfish-android   Author: PushFish   File: MavenPublishTaskModelRule.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(TaskContainer tasks, PublishingExtension extension) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();

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

        createGeneratePomTask(publication, publicationName);
        createLocalInstallTask(tasks, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publication, publicationName);
    }
}
 
Example #21
Source Project: pushfish-android   Author: PushFish   File: MavenPublishTaskModelRule.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
    }
}
 
Example #22
Source Project: pushfish-android   Author: PushFish   File: MavenPublishTaskModelRule.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example #23
Source Project: atlas   Author: alibaba   File: PublishToMavenRepositoryHook.java    License: Apache License 2.0 5 votes vote down vote up
@TaskAction
public void publish() {

    MavenPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    MavenArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #24
Source Project: Pushjet-Android   Author: Pushjet   File: PublishToMavenLocal.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            MavenPublisher antBackedPublisher = new AntTaskBackedMavenLocalPublisher(getLoggingManagerFactory(), getTemporaryDirFactory());
            MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher);
            MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
            validatingPublisher.publish(publication.asNormalisedPublication(), repository);
        }
    }.run();
}
 
Example #25
Source Project: Pushjet-Android   Author: Pushjet   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
public PublishToMavenRepository() {
    // Allow the publication to participate in incremental build
    getInputs().files(new Callable<FileCollection>() {
        public FileCollection call() throws Exception {
            MavenPublicationInternal publicationInternal = getPublicationInternal();
            return publicationInternal == null ? null : publicationInternal.getPublishableFiles();
        }
    });

    // Should repositories be able to participate in incremental?
    // At the least, they may be able to express themselves as output files
    // They *might* have input files and other dependencies as well though
    // Inputs: The credentials they need may be expressed in a file
    // Dependencies: Can't think of a case here
}
 
Example #26
Source Project: Pushjet-Android   Author: Pushjet   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static MavenPublicationInternal toPublicationInternal(MavenPublication publication) {
    if (publication == null) {
        return null;
    } else if (publication instanceof MavenPublicationInternal) {
        return (MavenPublicationInternal) publication;
    } else {
        throw new InvalidUserDataException(
                String.format(
                        "publication objects must implement the '%s' interface, implementation '%s' does not",
                        MavenPublicationInternal.class.getName(),
                        publication.getClass().getName()
                )
        );
    }
}
 
Example #27
Source Project: Pushjet-Android   Author: Pushjet   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@TaskAction
public void publish() {
    MavenPublicationInternal publicationInternal = getPublicationInternal();
    if (publicationInternal == null) {
        throw new InvalidUserDataException("The 'publication' property is required");
    }

    MavenArtifactRepository repository = getRepository();
    if (repository == null) {
        throw new InvalidUserDataException("The 'repository' property is required");
    }

    doPublish(publicationInternal, repository);
}
 
Example #28
Source Project: Pushjet-Android   Author: Pushjet   File: PublishToMavenRepository.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected void doPublish(final MavenPublicationInternal publication, final MavenArtifactRepository repository) {
    new PublishOperation(publication, repository) {
        @Override
        protected void publish() throws Exception {
            MavenPublisher antBackedPublisher = new AntTaskBackedMavenPublisher(getLoggingManagerFactory(), getTemporaryDirFactory());
            MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(antBackedPublisher);
            MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
            validatingPublisher.publish(publication.asNormalisedPublication(), repository);
        }
    }.run();
}
 
Example #29
Source Project: Pushjet-Android   Author: Pushjet   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
@SuppressWarnings("UnusedDeclaration")
public void realizePublishingTasks(CollectionBuilder<Task> tasks, @Path("tasks.publish") Task publishLifecycleTask, @Path("tasks.publishToMavenLocal") Task publishLocalLifecycleTask,
                                   PublishingExtension extension) {
    // Create generatePom tasks for any Maven publication
    PublicationContainer publications = extension.getPublications();

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

        createGeneratePomTask(tasks, publication, publicationName);
        createLocalInstallTask(tasks, publishLocalLifecycleTask, publication, publicationName);
        createPublishTasksForEachMavenRepo(tasks, extension, publishLifecycleTask, publication, publicationName);
    }
}
 
Example #30
Source Project: Pushjet-Android   Author: Pushjet   File: MavenPublishPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
        }
    });
}