Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Ski authored Oct 1, 2024
2 parents 4210073 + 7287d58 commit 60054a1
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 119 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build-pullrequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build pull request

on:
pull_request:
branches: [ master ]
permissions:
contents: read

jobs:
build-java:
if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
submodules: 'recursive'

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2

- name: Build & test Java code
run: |
./gradlew build
./gradlew test
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/[email protected]
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 }}
56 changes: 48 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,35 @@ if (JavaVersion.current().isJava8Compatible()) {
}

project(":gdx-ai") {
apply from : '../publish.gradle'
version project.getProperty('version') + (isReleaseBuild() ? "" : "-SNAPSHOT")

java {
withJavadocJar()
withSourcesJar()
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

tasks.withType(Test).configureEach {
systemProperty 'file.encoding', 'UTF-8'
}


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

apply from: '../publish.gradle'

}

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
7 changes: 1 addition & 6 deletions gdx-ai/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
apply plugin: "java"

sourceCompatibility = 1.7

Expand All @@ -7,10 +6,6 @@ sourceSets {
java {
srcDirs = [ "src/" ]
}

resources {
srcDirs = [ "src/" ]
}
}

test {
Expand All @@ -25,7 +20,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:[email protected]:libgdx/gdx-ai.git
POM_SCM_DEV_CONNECTION=scm:[email protected]: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
157 changes: 58 additions & 99 deletions publish.gradle
Original file line number Diff line number Diff line change
@@ -1,110 +1,69 @@
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 {
mavenJava(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}

repository(url: sonatypeRepositoryUrl) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
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
}
}
}
}

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:[email protected]:libgdx/gdx-ai.git'
connection 'scm:[email protected]:libgdx/gdx-ai.git'
developerConnection 'scm:[email protected]: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() }
}
}
}
}
Loading

0 comments on commit 60054a1

Please sign in to comment.