name.remal.gradleplugins.toolkit.buildlogic.publish-maven.gradle Maven / Gradle / Ivy
allprojects {
pluginManager.withPlugin('com.gradle.plugin-publish') {
apply plugin: 'maven-publish'
}
pluginManager.withPlugin('maven-publish') {
apply plugin: 'java'
publishing.publications.withType(MavenPublication) {
versionMapping {
usage('java-api') { fromResolutionOf('compileClasspath') }
usage('java-runtime') { fromResolutionOf('runtimeClasspath') }
}
moduleDescriptorGenerator = null
pom {
String displayName = property('repository-name')
String ownerName = property('repository-owner-name')
if (!ownerName.isEmpty()) {
displayName = "$ownerName: $displayName"
}
String subProjectName = project.path.substring(1).replace(':', ': ')
if (!subProjectName.isEmpty()) {
displayName = "$displayName: $subProjectName"
}
name = displayName
description = displayName
url = property('repository-html-url')
scm {
url = property('repository-html-url')
}
licenses {
license {
name = property('repository-license-name')
url = property('repository-license-html-url')
}
}
developers {
developer {
name = 'Semyon Levin'
email = '[email protected]'
id = email
}
}
}
}
afterEvaluate {
if (pluginManager.hasPlugin('java-library')
&& !pluginManager.hasPlugin('com.gradle.plugin-publish')
) {
java {
withJavadocJar()
withSourcesJar()
}
publishing.publications.create('mavenJavaLibrary', MavenPublication) {
from components.java
}
}
}
tasks.withType(GenerateModuleMetadata).configureEach { enabled = false }
pluginManager.withPlugin('signing') {
signing {
sign publishing.publications
}
}
}
tasks.register('generateAllPoms') {
group = 'publishing'
dependsOn(tasks.withType(GenerateMavenPom))
}
tasks.withType(AbstractPublishToMaven) {
mustRunAfter(
project.provider {
project.rootProject.allprojects
.collect {
it.tasks.matching {
return (
it.name == 'jar'
|| it.name == 'sourcesJar'
|| it.name == 'javadocJar'
|| it.name == 'allTests'
|| it instanceof AbstractCompile
|| it instanceof Javadoc
|| project.isVerificationTask(it)
)
}
}
.flatten()
.toList()
}
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy