Skip to content

Commit 2fa1113

Browse files
committed
packaging
1 parent f101b46 commit 2fa1113

File tree

9 files changed

+600
-169
lines changed

9 files changed

+600
-169
lines changed

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
release:
9+
types: [published]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build:
16+
name: Build (compile + test)
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Java
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version: "8"
28+
cache: gradle
29+
30+
- name: Build
31+
run: ./gradlew --no-daemon clean build
32+
33+
publish_github_packages:
34+
name: Publish to GitHub Packages (on Release)
35+
if: github.event_name == 'release'
36+
runs-on: ubuntu-latest
37+
38+
permissions:
39+
contents: read
40+
packages: write
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Set up Java
47+
uses: actions/setup-java@v4
48+
with:
49+
distribution: temurin
50+
java-version: "8"
51+
cache: gradle
52+
53+
- name: Resolve release version (from release name)
54+
id: ver
55+
shell: bash
56+
run: |
57+
set -euo pipefail
58+
VERSION="${{ github.event.release.name }}"
59+
if [ -z "${VERSION}" ]; then
60+
VERSION="${{ github.event.release.tag_name }}"
61+
fi
62+
# Optional: drop a leading "v" (common tag convention)
63+
VERSION="${VERSION#v}"
64+
65+
echo "releaseVersion=${VERSION}" >> "$GITHUB_OUTPUT"
66+
echo "Using releaseVersion=${VERSION}"
67+
68+
- name: Publish to GitHub Packages
69+
env:
70+
GITHUB_ACTOR: ${{ github.actor }}
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
./gradlew --no-daemon \
74+
-PreleaseVersion='${{ steps.ver.outputs.releaseVersion }}' \
75+
clean build \
76+
publishMavenJavaPublicationToGitHubPackagesRepository

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ bin/
44
build/
55
dependency-reduced-pom.xml
66
target/
7+
.gradle
8+
.vscode

build.gradle

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'signing'
5+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
6+
7+
}
8+
9+
group = 'org.jmonkeyengine'
10+
description = 'Drako for Java allows you to encode and decode Google Draco files with Java.'
11+
12+
def defaultVersion = '1.4.3'
13+
def releaseVersion = (findProperty('releaseVersion') ?: System.getenv('RELEASE_VERSION'))?.toString()
14+
15+
version = releaseVersion ?: defaultVersion
16+
17+
description = 'Drako for Java allows you to encode and decode Google Draco files with Java.'
18+
19+
repositories {
20+
mavenCentral()
21+
}
22+
23+
dependencies {
24+
testImplementation 'junit:junit:4.13.1'
25+
testImplementation 'org.hamcrest:hamcrest-core:1.3'
26+
}
27+
28+
java {
29+
toolchain {
30+
languageVersion = JavaLanguageVersion.of(8)
31+
}
32+
withSourcesJar()
33+
withJavadocJar()
34+
}
35+
sourceSets {
36+
main {
37+
java {
38+
srcDirs = [
39+
'src/compression',
40+
'src/decoder',
41+
'src/encoder',
42+
'src/draco',
43+
'src/generated',
44+
'src/helpers',
45+
'src/main',
46+
'src/utils'
47+
]
48+
}
49+
50+
}
51+
test {
52+
java {
53+
srcDirs = [ 'src/test']
54+
}
55+
}
56+
}
57+
58+
tasks.withType(JavaCompile).configureEach {
59+
options.encoding = 'UTF-8'
60+
options.fork = true
61+
options.compilerArgs += ['-Xmaxerrs', '100000']
62+
}
63+
64+
tasks.withType(Javadoc).configureEach {
65+
options.addStringOption('Xdoclint:none', '-quiet')
66+
}
67+
68+
tasks.test {
69+
useJUnit()
70+
workingDir = projectDir
71+
}
72+
73+
tasks.jar {
74+
manifest {
75+
attributes('Class-Path': '.')
76+
}
77+
archiveBaseName.set('drako')
78+
archiveVersion.set('')
79+
}
80+
81+
publishing {
82+
publications {
83+
mavenJava(MavenPublication) {
84+
from components.java
85+
86+
pom {
87+
name = 'drako'
88+
description = project.description
89+
url = 'https://github.com/jMonkeyEngine/openize-drako-java'
90+
91+
licenses {
92+
license {
93+
name = 'MIT License'
94+
url = 'https://raw.githubusercontent.com/jMonkeyEngine/openize-drako-java/main/LICENSE'
95+
}
96+
}
97+
98+
developers {
99+
developer {
100+
id = 'lexchou'
101+
name = 'Openize'
102+
organization = 'Openize Pty Ltd.'
103+
organizationUrl = 'https://www.openize.com'
104+
}
105+
106+
}
107+
108+
scm {
109+
url = 'https://github.com/jMonkeyEngine/openize-drako-java'
110+
}
111+
}
112+
}
113+
114+
}
115+
repositories {
116+
mavenLocal()
117+
118+
maven {
119+
name = "GitHubPackages"
120+
url = uri("https://maven.pkg.github.com/jMonkeyEngine/openize-drako-java")
121+
122+
credentials {
123+
username = (System.getenv("GITHUB_ACTOR") ?: findProperty("gpr.user"))?.toString()
124+
password = (System.getenv("GITHUB_TOKEN") ?: findProperty("gpr.key"))?.toString()
125+
}
126+
}
127+
}
128+
}
129+
130+
signing {
131+
// Only enable signing when keys are provided (keeps local builds working).
132+
def signingKey = findProperty('signingKey')
133+
def signingPassword = findProperty('signingPassword')
134+
135+
if (signingKey != null) {
136+
useInMemoryPgpKeys(signingKey.toString(), signingPassword?.toString())
137+
sign publishing.publications
138+
}
139+
}
140+
141+
nexusPublishing {
142+
repositories {
143+
sonatype {
144+
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
145+
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
146+
username = (System.getenv("OSSRH_USERNAME") ?: findProperty("ossrhUsername"))?.toString()
147+
password = (System.getenv("OSSRH_PASSWORD") ?: findProperty("ossrhPassword"))?.toString()
148+
}
149+
}
150+
}
151+
152+
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
153+
import org.gradle.api.publish.maven.tasks.PublishToMavenLocal
154+
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
155+
156+
tasks.withType(AbstractPublishToMaven).configureEach { t ->
157+
doFirst {
158+
def p = t.publication
159+
def coords = "${p.groupId}:${p.artifactId}:${p.version}"
160+
161+
if (t instanceof PublishToMavenRepository) {
162+
println "Publishing ${coords} -> ${t.repository.url} [${t.repository.name}]"
163+
} else if (t instanceof PublishToMavenLocal) {
164+
println "Publishing ${coords} -> mavenLocal()"
165+
} else {
166+
println "Publishing ${coords}"
167+
}
168+
}
169+
}

gradle/wrapper/gradle-wrapper.jar

44.6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)