publishing.gradle
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
apply plugin: 'maven'
apply plugin: "maven-publish"
def isProduction = Boolean.getBoolean('production')
def buildDateTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd.HH.mm.ss"))
version = isProduction ? buildDateTime + "PROD" : buildDateTime + "DEV-SNAPSHOT"
def initializePublishing(String targetGroupId, String targetArtifactId) {
publishing {
publications {
zipUpload(MavenPublication) {
groupId targetGroupId
artifactId targetArtifactId
artifact project.bootJar
}
}
repositories {
maven {
credentials {
username 'username'
password 'passwd'
}
def releaseRepoUrl = 'http://repositories/releases/'
def snapshotRepoUrl = 'http://repositories/snapshots/'
url version.endsWith('SNAPSHOT') ? snapshotRepoUrl : releaseRepoUrl
}
}
}
}
ext {
initializePublishing = this.&initializePublishing
}