org.gradle.api.publish.maven.MavenPublication Java Examples
The following examples show how to use
org.gradle.api.publish.maven.MavenPublication.
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 File: MavenPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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)); }
Example #2
Source File: MavenPublishPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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)); } }); }
Example #3
Source File: MavenPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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)); } }); }
Example #4
Source File: MavenPublishPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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)); }
Example #5
Source File: AndroidPublishPlugin.java From shipkit with MIT License | 5 votes |
public void apply(final Project project) { final AndroidPublishConfiguration androidPublishConfiguration = project.getExtensions().create(ANDROID_PUBLISH_EXTENSION, AndroidPublishConfiguration.class); final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration(); project.getPlugins().apply(LocalSnapshotPlugin.class); Task snapshotTask = project.getTasks().getByName(LocalSnapshotPlugin.SNAPSHOT_TASK); snapshotTask.dependsOn(MAVEN_LOCAL_TASK); project.getPlugins().apply("maven-publish"); BintrayExtension bintray = project.getExtensions().getByType(BintrayExtension.class); bintray.setPublications(PUBLICATION_NAME); project.getPlugins().withId("com.android.library", plugin -> { deferredConfiguration(project, () -> { GradleDSLHelper.publications(project, publications -> { MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, publication -> { publication.setArtifactId(androidPublishConfiguration.getArtifactId()); SoftwareComponent releaseComponent = project.getComponents().findByName("release"); if (releaseComponent == null) { throw new GradleException("'release' component not found in project. " + "Make sure you are using Android Gradle Plugin 3.6.0-beta05 or newer."); } publication.from(releaseComponent); PomCustomizer.customizePom(project, conf, publication); }); LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId()); }); }); //so that we flesh out problems with maven publication during the build process project.getTasks().getByName("build").dependsOn(MAVEN_LOCAL_TASK); }); }
Example #6
Source File: MavenPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public MavenPublication create(final String name) { Module module = dependencyMetaDataProvider.getModule(); MavenProjectIdentity projectIdentity = new DefaultMavenProjectIdentity(module.getGroup(), module.getName(), module.getVersion()); NotationParser<Object, MavenArtifact> artifactNotationParser = new MavenArtifactNotationParserFactory(instantiator, fileResolver).create(); return instantiator.newInstance( DefaultMavenPublication.class, name, projectIdentity, artifactNotationParser, instantiator, projectDependencyResolver ); }
Example #7
Source File: PublishToMavenRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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 #8
Source File: MavenPublishPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public MavenPublication create(final String name) { Module module = dependencyMetaDataProvider.getModule(); MavenProjectIdentity projectIdentity = new DefaultMavenProjectIdentity(module.getGroup(), module.getName(), module.getVersion()); NotationParser<Object, MavenArtifact> artifactNotationParser = new MavenArtifactNotationParserFactory(instantiator, fileResolver).create(); return instantiator.newInstance( DefaultMavenPublication.class, name, projectIdentity, artifactNotationParser, instantiator, projectDependencyResolver ); }
Example #9
Source File: PublishToMavenRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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 #10
Source File: MavenPublishBasePlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; project.getPlugins().apply(getPluginClass()); project.getPlugins().apply(MavenPublishPlugin.class); publication = project.getExtensions().getByType(PublishingExtension.class) .getPublications() .create(getPublicationName(), MavenPublication.class); project.afterEvaluate(p -> { publication.from(getSoftwareComponent()); project.getPlugins().withType(SourcesJarPlugin.class, sourcesJarPlugin -> { Jar sourcesJar = sourcesJarPlugin.getSourcesJar().get(); publication.artifact(sourcesJar); }); project.getPlugins().withType(JavadocJarPlugin.class, javadocJarPlugin -> { Jar javadocJar = javadocJarPlugin.getJavadocJar().get(); publication.artifact(javadocJar); }); project.getPlugins().withType(SigningPlugin.class, signingPlugin -> project.getExtensions() .getByType(SigningExtension.class) .sign(publication) ); }); }
Example #11
Source File: GithubPomPlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; githubBasePlugin = project.getRootProject().getPlugins().apply(GithubBasePlugin.class); githubExtension = githubBasePlugin.getGithubExtension(); githubService = githubBasePlugin.getGithubClient().getGithubService(); project.getPlugins().withType(PublishingPlugin.class, publishingPlugin -> { project.getExtensions().getByType(PublishingExtension.class).getPublications() .withType(MavenPublication.class, this::configureMavenPublication); }); }
Example #12
Source File: PomCustomizer.java From shipkit with MIT License | 5 votes |
/** * Customizes the pom. The method requires following properties on root project to function correctly: */ public static void customizePom(final Project project, final ShipkitConfiguration conf, final MavenPublication publication) { publication.getPom().withXml(new Action<XmlProvider>() { public void execute(XmlProvider xml) { String archivesBaseName = (String) project.getProperties().get("archivesBaseName"); File contributorsFile = contributorsFile(project); LOG.info(" Read project contributors from file: " + contributorsFile.getAbsolutePath()); // It can happens that contributorsFile doesn't exist e.g. when shipkit.team.contributors is NOT empty ProjectContributorsSet contributorsFromGitHub = new ProjectContributorsSerializer() .deserialize(IOUtil.readFullyOrDefault(contributorsFile, "[]")); LOG.info(" Customizing pom for publication " + publication.getName() + " in " + project.toString() + "\n - Module name (project.archivesBaseName): " + archivesBaseName + "\n - Description (project.description): " + project.getDescription() + "\n - GitHub repository (project.rootProject.shipkit.gitHub.repository): " + conf.getGitHub().getRepository() + "\n - Developers (project.rootProject.shipkit.team.developers): " + StringUtil.join(conf.getTeam().getDevelopers(), ", ") + "\n - Contributors (project.rootProject.shipkit.team.contributors): " + StringUtil.join(conf.getTeam().getContributors(), ", ") + "\n - Contributors read from GitHub: " + StringUtil.join(contributorsFromGitHub.toConfigNotation(), ", ")); final boolean isAndroidLibrary = project.getPlugins().hasPlugin("com.android.library"); customizePom(xml.asNode(), conf, archivesBaseName, project.getDescription(), contributorsFromGitHub, isAndroidLibrary); } }); }
Example #13
Source File: JavaPublishPlugin.java From shipkit with MIT License | 5 votes |
public void apply(final Project project) { final ShipkitConfiguration conf = project.getPlugins().apply(ShipkitConfigurationPlugin.class).getConfiguration(); project.getPlugins().apply(LocalSnapshotPlugin.class); Task snapshotTask = project.getTasks().getByName(LocalSnapshotPlugin.SNAPSHOT_TASK); snapshotTask.dependsOn(MAVEN_LOCAL_TASK); project.getPlugins().apply(JavaLibraryPlugin.class); project.getPlugins().apply("maven-publish"); final Jar sourcesJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.SOURCES_JAR_TASK); final Jar javadocJar = (Jar) project.getTasks().getByName(JavaLibraryPlugin.JAVADOC_JAR_TASK); GradleDSLHelper.publications(project, publications -> { MavenPublication p = publications.create(PUBLICATION_NAME, MavenPublication.class, publication -> { publication.from(project.getComponents().getByName("java")); publication.artifact(sourcesJar); publication.artifact(javadocJar); DeferredConfiguration.deferredConfiguration(project, () -> { publication.setArtifactId(((Jar) project.getTasks().getByName("jar")).getBaseName()); }); PomCustomizer.customizePom(project, conf, publication); }); LOG.info("{} - configured '{}' publication", project.getPath(), p.getArtifactId()); }); //so that we flesh out problems with maven publication during the build process project.getTasks().getByName("build").dependsOn(MAVEN_LOCAL_TASK); }
Example #14
Source File: MavenPublishBasePlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; project.getPlugins().apply(getPluginClass()); project.getPlugins().apply(MavenPublishPlugin.class); publication = project.getExtensions().getByType(PublishingExtension.class) .getPublications() .create(getPublicationName(), MavenPublication.class); project.afterEvaluate(p -> { publication.from(getSoftwareComponent()); project.getPlugins().withType(SourcesJarPlugin.class, sourcesJarPlugin -> { Jar sourcesJar = sourcesJarPlugin.getSourcesJar().get(); publication.artifact(sourcesJar); }); project.getPlugins().withType(JavadocJarPlugin.class, javadocJarPlugin -> { Jar javadocJar = javadocJarPlugin.getJavadocJar().get(); publication.artifact(javadocJar); }); project.getPlugins().withType(SigningPlugin.class, signingPlugin -> project.getExtensions() .getByType(SigningExtension.class) .sign(publication) ); }); }
Example #15
Source File: GithubPomPlugin.java From gradle-plugins with MIT License | 5 votes |
@Override public void apply(Project project) { this.project = project; githubBasePlugin = project.getRootProject().getPlugins().apply(GithubBasePlugin.class); githubExtension = githubBasePlugin.getGithubExtension(); githubService = githubBasePlugin.getGithubClient().getGithubService(); project.getPlugins().withType(PublishingPlugin.class, publishingPlugin -> { project.getExtensions().getByType(PublishingExtension.class).getPublications() .withType(MavenPublication.class, this::configureMavenPublication); }); }
Example #16
Source File: Publisher.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
public void decorate(FirebaseLibraryExtension library, MavenPublication publication) { publication.setVersion(determineVersion(library)); publication .getPom() .withXml( xml -> { Element rootElement = xml.asElement(); validatePomXml(library, rootElement); processDependencies(library, rootElement); }); }
Example #17
Source File: MavenPublishPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public MavenPublication create(final String name) { Module module = dependencyMetaDataProvider.getModule(); MavenProjectIdentity projectIdentity = new DefaultMavenProjectIdentity(module.getGroup(), module.getName(), module.getVersion()); NotationParser<Object, MavenArtifact> artifactNotationParser = new MavenArtifactNotationParserFactory(instantiator, fileResolver).create(); return instantiator.newInstance( DefaultMavenPublication.class, name, projectIdentity, artifactNotationParser, instantiator, projectDependencyResolver ); }
Example #18
Source File: PublishToMavenRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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 #19
Source File: MavenPublishPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public MavenPublication create(final String name) { Module module = dependencyMetaDataProvider.getModule(); MavenProjectIdentity projectIdentity = new DefaultMavenProjectIdentity(module.getGroup(), module.getName(), module.getVersion()); NotationParser<Object, MavenArtifact> artifactNotationParser = new MavenArtifactNotationParserFactory(instantiator, fileResolver).create(); return instantiator.newInstance( DefaultMavenPublication.class, name, projectIdentity, artifactNotationParser, instantiator, projectDependencyResolver ); }
Example #20
Source File: PublishToMavenRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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 #21
Source File: GithubPomPlugin.java From gradle-plugins with MIT License | 4 votes |
private void configureMavenPublication(MavenPublication mavenPublication) { mavenPublication.pom(pom -> { pom.getUrl().convention(getRepo().map(repo -> hasText(repo.getHomepage()).orElse(repo.getHtml_url()))); pom.getDescription().convention(getRepo().flatMap(repo -> project.provider(() -> hasText(repo.getDescription()).orElse(project.getDescription())))); pom.getName().convention(project.getName()); pom.getInceptionYear().convention(getRepo().map(repo -> repo.getCreated_at().substring(0, 4))); pom.organization(organization -> { organization.getName().convention(getUser().map(user -> hasText(user.getName()).orElse(user.getLogin()))); organization.getUrl().convention(getUser().map(user -> hasText(user.getBlog()).orElse(user.getHtml_url()))); }); project.afterEvaluate(rp -> { if (githubExtension.getTravis().getOrElse(false)) { pom.ciManagement(ciManagement -> { ciManagement.getSystem().convention("Travis CI"); ciManagement.getUrl().convention(githubExtension.getSlug().map(slug -> String.format("https://travis-ci.org/%s/", slug))); }); } if (getRepo().map(Repo::isHas_issues).getOrElse(true)) { pom.issueManagement(issueManagement -> { issueManagement.getSystem().convention("GitHub Issues"); issueManagement.getUrl().convention(githubExtension.getSlug().map(slug -> String.format("https://github.com/%s/issues", slug))); }); } if (getLicense().isPresent() && ((MavenPomInternal) pom).getLicenses().isEmpty()) { pom.licenses(licences -> { licences.license(licence -> { licence.getName().convention(getLicense().map(License::getName)); licence.getUrl().convention(getLicense().map(License::getHtml_url)); licence.getComments().convention(getLicense().map(License::getDescription)); }); }); } }); pom.scm(scm -> { scm.getUrl().convention(getRepo().map(Repo::getHtml_url)); scm.getConnection().convention(getRepo().map(repo -> "scm:git:" + repo.getClone_url())); scm.getDeveloperConnection().convention(scm.getConnection()); scm.getTag().convention(githubExtension.getTag()); }); }); }
Example #22
Source File: GithubPomPlugin.java From gradle-plugins with MIT License | 4 votes |
private void configureMavenPublication(MavenPublication mavenPublication) { mavenPublication.pom(pom -> { pom.getUrl().convention(getRepo().map(repo -> hasText(repo.getHomepage()).orElse(repo.getHtml_url()))); pom.getDescription().convention(getRepo().flatMap(repo -> project.provider(() -> hasText(repo.getDescription()).orElse(project.getDescription())))); pom.getName().convention(project.getName()); pom.getInceptionYear().convention(getRepo().map(repo -> repo.getCreated_at().substring(0, 4))); pom.organization(organization -> { organization.getName().convention(getUser().map(user -> hasText(user.getName()).orElse(user.getLogin()))); organization.getUrl().convention(getUser().map(user -> hasText(user.getBlog()).orElse(user.getHtml_url()))); }); project.afterEvaluate(rp -> { if (githubExtension.getTravis().getOrElse(false)) { pom.ciManagement(ciManagement -> { ciManagement.getSystem().convention("Travis CI"); ciManagement.getUrl().convention(githubExtension.getSlug().map(slug -> String.format("https://travis-ci.org/%s/", slug))); }); } if (getRepo().map(Repo::isHas_issues).getOrElse(true)) { pom.issueManagement(issueManagement -> { issueManagement.getSystem().convention("GitHub Issues"); issueManagement.getUrl().convention(githubExtension.getSlug().map(slug -> String.format("https://github.com/%s/issues", slug))); }); } if (getLicense().isPresent() && ((MavenPomInternal) pom).getLicenses().isEmpty()) { pom.licenses(licences -> { licences.license(licence -> { licence.getName().convention(getLicense().map(License::getName)); licence.getUrl().convention(getLicense().map(License::getHtml_url)); licence.getComments().convention(getLicense().map(License::getDescription)); }); }); } }); pom.scm(scm -> { scm.getUrl().convention(getRepo().map(Repo::getHtml_url)); scm.getConnection().convention(getRepo().map(repo -> "scm:git:" + repo.getClone_url())); scm.getDeveloperConnection().convention(scm.getConnection()); scm.getTag().convention(githubExtension.getTag()); }); }); }
Example #23
Source File: PublishToMavenRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sets the publication to be published. * * @param publication The publication to be published */ public void setPublication(MavenPublication publication) { this.publication = toPublicationInternal(publication); }
Example #24
Source File: PublishToMavenRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sets the publication to be published. * * @param publication The publication to be published */ public void setPublication(MavenPublication publication) { this.publication = toPublicationInternal(publication); }
Example #25
Source File: PublishToMavenRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 2 votes |
/** * The publication to be published. * * @return The publication to be published */ public MavenPublication getPublication() { return publication; }
Example #26
Source File: PublishToMavenRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 2 votes |
/** * The publication to be published. * * @return The publication to be published */ public MavenPublication getPublication() { return publication; }
Example #27
Source File: PublishToMavenRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sets the publication to be published. * * @param publication The publication to be published */ public void setPublication(MavenPublication publication) { this.publication = toPublicationInternal(publication); }
Example #28
Source File: PublishToMavenRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sets the publication to be published. * * @param publication The publication to be published */ public void setPublication(MavenPublication publication) { this.publication = toPublicationInternal(publication); }
Example #29
Source File: PublishToMavenRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 2 votes |
/** * The publication to be published. * * @return The publication to be published */ public MavenPublication getPublication() { return publication; }
Example #30
Source File: PublishToMavenRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 2 votes |
/** * The publication to be published. * * @return The publication to be published */ public MavenPublication getPublication() { return publication; }