Skip to content

Commit

Permalink
Gradle publish on Sonatype
Browse files Browse the repository at this point in the history
  • Loading branch information
git-init-wesley committed May 6, 2021
1 parent 1191c9f commit f53d2af
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
49 changes: 33 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
plugins {
id 'java'
id 'maven-publish'
id 'signing'
}

group BUILD_GROUP
version BUILD_VERSION
archivesBaseName = BUILD_NAME

java.sourceCompatibility JavaVersion.VERSION_11
java.targetCompatibility JavaVersion.VERSION_16
Expand All @@ -27,6 +29,26 @@ test {
useJUnitPlatform()
}

task sourcesJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allJava
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives jar
archives sourcesJar
archives javadocJar
}

signing {
sign configurations.archives
}

java {
manifest {
attributes 'Build-By': BUILD_AUTHOR,
Expand All @@ -48,26 +70,17 @@ javadoc {
publishing {
repositories {
maven {
if (System.getenv("SonaType") != null) {
def releasesRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
def snapshotsRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
url = version.contains('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}else {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/" + BUILD_OWNER + "/" + BUILD_NAME)
credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
}
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
url = version.contains('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv('oss_username')
password = System.getenv('oss_password')
}
}
}
publications {
mavenJava(MavenPublication) {
groupId = BUILD_GROUP_ID
artifactId = BUILD_NAME
version = BUILD_VERSION
from components.java
pom {
name = BUILD_NAME
description = BUILD_DESCRIPTION
Expand All @@ -81,7 +94,7 @@ publishing {
}
developers {
developer {
id = BUILD_GROUP_ID
id = 'levasseur.wesley'
name = 'Levasseur Wesley'
email = 'contact@wesley-dev.codes'
}
Expand All @@ -93,6 +106,10 @@ publishing {
tag = 'HEAD'
}
}
groupId = BUILD_GROUP_ID
artifactId = BUILD_ARTIFACT_ID
version = BUILD_VERSION
from components.java
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Importants
BUILD_GROUP=codes.wesley_.remasteredlogger
BUILD_GROUP_ID=codes.wesley-dev
BUILD_ARTIFACT_ID=remasteredlogger
# Informations
BUILD_NAME=RemasteredLogger
BUILD_URL=https://github.com/kanekireal/RemasteredLogger
Expand Down

0 comments on commit f53d2af

Please sign in to comment.