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+ }
0 commit comments