Skip to content

Commit

Permalink
Merge pull request #216 from cognizone/ci/publish-to-nexus-and-maven-…
Browse files Browse the repository at this point in the history
…central

Ci/publish to nexus and maven central
  • Loading branch information
nikos-papantoniou authored Sep 8, 2023
2 parents e7d9307 + 3be090e commit f7395ad
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 12 deletions.
95 changes: 84 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ subprojects {
apply plugin: "idea"
apply plugin: "io.spring.dependency-management"
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'project-report'

repositories {
Expand Down Expand Up @@ -125,18 +126,26 @@ subprojects {
useJUnitPlatform()
}

task sourcesJar(type: Jar) {
description = 'Creates sources JAR.'
archiveClassifier = 'sources'
jar {
from("${projectDir}") {
include 'LICENSE'
into '/'
}
from("${projectDir}") {
include 'LICENSE'
into 'META-INF'
}
}

from sourceSets.main.allSource
java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
Expand All @@ -145,19 +154,83 @@ subprojects {
fromResolutionResult()
}
}
pom {
name = 'asquare'
packaging = 'jar'
// optionally artifactId can be defined here
description = 'Library for Semantic Development'
url = 'https://github.com/cognizone/asquare'

scm {
connection = 'scm:git:[email protected]:cognizone/asquare.git'
developerConnection = 'scm:git:[email protected]:cognizone/asquare.git'
url = 'https://github.com/cognizone/asquare'
}

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id = 'cognizone'
name = 'Cognizone'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
credentials {
username = System.properties['archiva.user']
password = System.properties['archiva.password']
if (project.hasProperty("publishToCognizoneArchiva")) {
maven {
credentials {
username = System.properties['archiva.username']
password = System.properties['archiva.password']
}
name = 'public'
url = System.properties['archiva.url']
}
}
if (project.hasProperty("publishToCognizoneNexus")) {
maven {
credentials {
username = System.properties['nexus.username']
password = System.properties['nexus.password']
}
def releasesRepoUrl = "${System.properties['nexus.url']}/repository/cognizone-release"
def snapshotsRepoUrl = "${System.properties['nexus.url']}/repository/cognizone-snapshot"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
allowInsecureProtocol(true)
}
}
if (project.hasProperty("publishToMavenCentral")) {
maven {
credentials {
username = System.properties['ossrh.username']
password = System.properties['ossrh.password']
}
// We cannot directly release to Maven Central, we first need to publish on staging repo
// then manually release through the UI in https://s01.oss.sonatype.org/ (login with JIRA)
def stagingRepoUrl = "${System.properties['ossrh.url']}/content/groups/staging"
def snapshotsRepoUrl = "${System.properties['ossrh.url']}/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : stagingRepoUrl
}
name = 'public'
url = System.properties['archiva.url']
}
}
}

signing {
sign publishing.publications.mavenJava
}

tasks.withType(Javadoc) {
failOnError false
}

build.finalizedBy(tasks.publishToMavenLocal)
}

Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
systemProp.archiva.url=xxx
systemProp.archiva.user=xx
systemProp.archiva.username=xx
systemProp.archiva.password=xx
systemProp.nexus.username=xx
systemProp.nexus.password=xx
systemProp.nexus.url=xx

0 comments on commit f7395ad

Please sign in to comment.