Skip to content

Commit

Permalink
update gradle to 8.4. Migrate to new publishing flow, allowing for sn…
Browse files Browse the repository at this point in the history
…apshots and release using actions
  • Loading branch information
Tom-Ski committed Oct 1, 2024
1 parent d3a0c8d commit a3248e7
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 114 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build and deploy

on:
push:
branches: [ master ]
release:
types: [ published ]

env:
GRADLE_USER_HOME: .gradle

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Upload all output libs
uses: actions/upload-artifact@v2.1.4
with:
name: output-libs
path: "*/build/libs"

- name: Snapshot build deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'libgdx'
run: ./gradlew build publish
env:
ORG_GRADLE_PROJECT_NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}

- name: Import GPG key
if: github.event_name == 'release' && github.repository_owner == 'libgdx'
id: import_gpg
uses: crazy-max/ghaction-import-gpg@1c6a9e9d3594f2d743f1b1dd7669ab0dfdffa922
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Release build deploy
if: github.event_name == 'release' && github.repository_owner == 'libgdx'
run: ./gradlew build publish -PRELEASE -Psigning.gnupg.keyId=${{ secrets.GPG_KEYID }} -Psigning.gnupg.passphrase=${{ secrets.GPG_PASSPHRASE }} -Psigning.gnupg.keyName=${{ secrets.GPG_KEYID }}
env:
ORG_GRADLE_PROJECT_NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
39 changes: 31 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'java-library'

repositories {
mavenCentral()
Expand All @@ -19,8 +19,31 @@ allprojects {
}

ext {
projectGroup = "gdx-ai"
gdxVersion = '1.11.0'
projectGroup = "gdx-ai"
gdxVersion = '1.11.0'

isReleaseBuild = {
return project.hasProperty("RELEASE")
}

getReleaseRepositoryUrl = {
return project.hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

getSnapshotRepositoryUrl = {
return project.hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

getRepositoryUsername = {
return project.hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}

getRepositoryPassword = {
return project.hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}

}

/** needed to disable Java 8 doclint which throws errors **/
Expand All @@ -33,18 +56,18 @@ if (JavaVersion.current().isJava8Compatible()) {
}

project(":gdx-ai") {
apply from : '../publish.gradle'
apply from: '../publish.gradle'

dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}

project(":tests") {
dependencies {
compile project(":gdx-ai")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
implementation project(":gdx-ai")
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
}

Expand Down
2 changes: 1 addition & 1 deletion gdx-ai/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ javadoc {
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
}

idea.module.excludeDirs += [file("src/com/badlogic/gdx/emu/")]
Expand Down
12 changes: 12 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx512m -Dfile.encoding=UTF-8 -Dconsole.encoding=UTF-8
org.gradle.configureondemand=false

group=com.badlogicgames.gdx
version=1.8.3
POM_DESCRIPTION=AI algorithms for libGDX
POM_NAME=libGDX AI
POM_URL=https://github.com/libgdx/gdx-ai
POM_SCM_URL=https://github.com/libgdx/gdx-ai
POM_SCM_CONNECTION=scm:git@github.com:libgdx/gdx-ai.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:libgdx/gdx-ai.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
163 changes: 64 additions & 99 deletions publish.gradle
Original file line number Diff line number Diff line change
@@ -1,110 +1,75 @@
import org.gradle.api.XmlProvider
import org.gradle.api.artifacts.maven.MavenDeployment

apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'

group = 'com.badlogicgames.gdx'
version = '1.8.3'
ext.packaging = 'jar'

def isDevBuild
def isCiBuild
def isReleaseBuild

def sonatypeRepositoryUrl

//set build variables based on build type (release, continuous integration, development)
if(hasProperty("release")) {
isReleaseBuild = true
sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
println "Performing release build"
} else if (hasProperty("snapshot")) {
isCiBuild = true
version += "-SNAPSHOT"
sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
println "Performing snapshot build"
} else {
isDevBuild = true
version += "-SNAPSHOT"
println "Performing local build"
}

repositories {
mavenCentral()
}

task artifactDocs(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}

task artifactSources(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives jar
archives artifactDocs
archives artifactSources
}

if(isReleaseBuild) {
signing {
sign configurations.archives
}
} else {
task signArchives {
// do nothing
}
}

uploadArchives {
repositories {
if (isDevBuild) {
mavenLocal()
}
else {
mavenDeployer {
if(isReleaseBuild) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
afterEvaluate { project ->
publishing {
publications {
withType(MavenPublication) {
pom {
name = POM_NAME
description = POM_DESCRIPTION
url = POM_URL
licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
distribution = POM_LICENCE_DIST
}
}
developers {
developer {
id = "davebaol"
name = "davebaol"
}
}
scm {
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
url = POM_SCM_URL
}
}

repository(url: sonatypeRepositoryUrl) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
//Check if we are a gradle plugin, if we are skip mavenJava
if (!plugins.hasPlugin('java-gradle-plugin')) {
mavenJava(MavenPublication) {

from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
}

pom.version = version
pom.packaging = 'jar'

pom.project {
name 'libGDX AI'
description 'AI algorithms for libGDX'
url 'https://github.com/libgdx/gdx-ai'
repositories {
maven {
url = version.endsWith('SNAPSHOT') ? getSnapshotRepositoryUrl() : getReleaseRepositoryUrl()

scm {
url 'scm:git@github.com:libgdx/gdx-ai.git'
connection 'scm:git@github.com:libgdx/gdx-ai.git'
developerConnection 'scm:git@github.com:libgdx/gdx-ai.git'
}
if (getRepositoryUsername() || getRepositoryPassword()) {
credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
}
}
}
}
}

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
signing {
useGpgCmd()
sign publishing.publications
}

developers {
developer {
id 'davebaol'
name 'davebaol'
}
}
}
}
//Simply using "required" in signing block doesn't work because taskGraph isn't ready yet.
gradle.taskGraph.whenReady {
tasks.withType(Sign) {
onlyIf { isReleaseBuild() }
}
}
}
}
10 changes: 5 additions & 5 deletions tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ sourceCompatibility = 1.7
sourceSets.main.java.srcDirs = [ "src/" ]

dependencies {
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
compile "com.esotericsoftware:kryo:3.0.3"
implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
implementation "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
implementation "com.esotericsoftware:kryo:3.0.3"
}

eclipse.project {
Expand Down

0 comments on commit a3248e7

Please sign in to comment.