Skip to content

Commit

Permalink
Fixup for maven publication
Browse files Browse the repository at this point in the history
  • Loading branch information
vroyer committed Oct 18, 2019
1 parent 18076ba commit 2339d32
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
14 changes: 12 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,21 @@ deploy:
on:
tags: true
repo: strapdata/elassandra-rc
# publish artifact in strapdata nexus

# publish snapshot artifact in strapdata nexus
- provider: script
skip_cleanup: true
script:
- ./gradlew publish -Dstrapdata.mavenMirror=true -Dbuild.snapshot=false -PstrapdataNexusUsername="${NEXUS_USERNAME}" -PstrapdataNexusPassword="${NEXUS_PASSWORD}" -PstrapdataNexusUrl="$NEXUS_URL/maven-releases-public/"
- ./gradlew publish -PrepoUsername="${NEXUS_USERNAME}" -PrepoPassword="${NEXUS_PASSWORD}" -PrepoUrl="$NEXUS_URL/maven-snapshots/"
on:
tags: false
repo: strapdata/elassandra

# publish release artifact in strapdata nexus
- provider: script
skip_cleanup: true
script:
- ./gradlew publish -Dbuild.snapshot=false -PrepoUsername="${NEXUS_USERNAME}" -PrepoPassword="${NEXUS_PASSWORD}" -PrepoUrl="$NEXUS_URL/maven-releases-public/"
on:
tags: true
repo: strapdata/elassandra
Expand Down
51 changes: 27 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ subprojects {
ext.enableArtifactSigning = !version.endsWith("SNAPSHOT") && project.hasProperty("repoUsername")
ext.repoUsername = { project.hasProperty("repoUsername") ? getProperty("repoUsername") : "" }
ext.repoPassword = { project.hasProperty("repoPassword") ? getProperty("repoPassword") : "" }

// added by strapdata to publish artifact on an internal nexus
if (!project.hasProperty("strapdataNexusUrl")) { ext.strapdataNexusUrl = "" }
if (!project.hasProperty("strapdataNexusUsername")) { ext.strapdataNexusUsername = "" }
if (!project.hasProperty("strapdataNexusPassword")) { ext.strapdataNexusPassword = "" }
// repoUrl can override the publication repo URL.

Path rootPath = rootDir.toPath()
// setup pom license info, but only for artifacts that are part of elasticsearch
Expand All @@ -74,23 +70,25 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) {

repositories {
mavenLocal()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}

// we only use maven publish to add tasks for pom generation
plugins.withType(MavenPublishPlugin).whenPluginAdded {
publishing {
repositories {
maven {
name "deploy"
url strapdataNexusUrl
credentials {
username = strapdataNexusUsername
password = strapdataNexusPassword
}
}
credentials {
username = repoUsername
password = repoPassword
}
if (project.hasProperty("repoUrl")) {
url project.getProperty("repoUrl")
} else if(project.version.endsWith('-SNAPSHOT')) {
url "https://oss.sonatype.org/content/repositories/snapshots/"
} else {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
}
}
publications {
// add license information to generated poms
Expand Down Expand Up @@ -137,15 +135,20 @@ configure(subprojects.findAll { it.projectDir.toPath().startsWith(rootPath) }) {
// POM signature
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

// Target repository
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: repoUsername, password: repoPassword)
}

// SNAPSHOT repository
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: repoUsername, password: repoPassword)
}
if (project.hasProperty("repoUrl")) {
repository(url: project.getProperty("repoUrl")) {
authentication(userName: repoUsername, password: repoPassword)
}
} else if(project.version.endsWith('-SNAPSHOT')) {
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: repoUsername, password: repoPassword)
}
} else {
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: repoUsername, password: repoPassword)
}
}

pom.withXml { XmlProvider xml ->
Node node = xml.asNode()
node.appendNode('name',it.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,12 @@ class BuildPlugin implements Plugin<Project> {
repos.maven {
url System.getenv("NEXUS_URL")
credentials {
username System.getenv("NEXUS_USER")
username System.getenv("NEXUS_USERNAME")
password System.getenv("NEXUS_PASSWORD")
}
}
}
else {
repos.mavenCentral()
}
repos.mavenCentral()

String luceneVersion = VersionProperties.lucene
if (luceneVersion.contains('-snapshot')) {
Expand Down

0 comments on commit 2339d32

Please sign in to comment.