Started maven publish plugin.
This commit is contained in:
parent
85d230c561
commit
9b23d713ff
46
build.gradle
46
build.gradle
|
@ -10,6 +10,7 @@ tasks.withType(JavaCompile) {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'signing'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -268,11 +269,27 @@ jacocoTestReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
task publishToMavenCentral() {
|
||||||
Properties props = new Properties()
|
dependsOn publish
|
||||||
if(file("$buildDir/credentials.properties").exists()) {
|
group 'publishing'
|
||||||
props.load(new FileInputStream("$buildDir/credentials.properties"))
|
description 'Publishes to Maven Central'
|
||||||
|
doLast {
|
||||||
|
System.out.println("Published To Maven Central")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def isPublishingToMavenCentral() {
|
||||||
|
return gradle.startParameter.taskNames.contains('publishToMavenCentral');
|
||||||
|
}
|
||||||
|
|
||||||
|
signing {
|
||||||
|
required { isPublishingToMavenCentral() }
|
||||||
|
useGpgCmd()
|
||||||
|
sign configurations.archives
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
def isMavenCentral = isPublishingToMavenCentral()
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
pom {
|
pom {
|
||||||
|
@ -281,7 +298,7 @@ publishing {
|
||||||
url = 'https://github.com/Speiger/Primitive-Collections'
|
url = 'https://github.com/Speiger/Primitive-Collections'
|
||||||
version = project.version
|
version = project.version
|
||||||
artifactId = project.archivesBaseName.replace(" ", "-")
|
artifactId = project.archivesBaseName.replace(" ", "-")
|
||||||
groupId = 'de.speiger'
|
groupId = isMavenCentral ? 'io.github.speiger' : 'de.speiger'
|
||||||
from components.java
|
from components.java
|
||||||
artifact tasks.srcJar
|
artifact tasks.srcJar
|
||||||
artifact tasks.javadocJar
|
artifact tasks.javadocJar
|
||||||
|
@ -309,10 +326,21 @@ publishing {
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url version.endsWith('SNAPSHOT') ? "https://maven.speiger.com/repository/debug" : "https://maven.speiger.com/repository/main"
|
if(isMavenCentral) {
|
||||||
credentials(PasswordCredentials) {
|
def auth = System.getenv("Maven_Central_Auth").split(';');
|
||||||
username props.mavenUser
|
url version.endsWith('SNAPSHOT') ? "https://s01.oss.sonatype.org/content/repositories/snapshots/" : "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||||
password props.mavenPassword
|
credentials {
|
||||||
|
username auth[0]
|
||||||
|
password auth[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
def auth = System.getenv("Speiger_Maven_Auth").split(';');
|
||||||
|
url version.endsWith('SNAPSHOT') ? "https://maven.speiger.com/repository/debug" : "https://maven.speiger.com/repository/main"
|
||||||
|
credentials(PasswordCredentials) {
|
||||||
|
username auth[0]
|
||||||
|
password auth[1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue