Futzing with Gradle build. This seems to build the right POM, upload the right files, and build the JAR files correctly.

This commit is contained in:
Rob Greene 2018-03-10 00:21:09 -06:00
parent 41ac815c42
commit c5a69c0673
2 changed files with 160 additions and 77 deletions

View File

@ -8,6 +8,8 @@ repositories {
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'maven'
apply plugin: 'signing'
mainClassName = 'com.webcodepro.applecommander.ui.AppleCommander'
version "${version}"
@ -36,25 +38,22 @@ test {
}
// Disable default JAR creation
jar {
enabled = false
}
project.tasks.remove(jar)
tasks.withType(Javadoc) {
// disable the crazy super-strict doclint tool in Java 8
options.addStringOption('Xdoclint:none', '-quiet')
}
// Generic additions to JAR creation
tasks.withType(Jar) {
manifest {
attributes 'Main-Class': 'com.webcodepro.applecommander.ui.AppleCommander'
attributes 'Implementation-Title': 'AppleCommander',
'Implementation-Version': version
}
from('LICENSE', 'CONTRIB', 'TODO', 'VERSIONS')
from('LICENSE')
doFirst {
// Pick and include ShrinkIt contents
// Jar files with an appendix are standalone applications and need to have ShrinkIt included.
if (appendix) {
from { configurations.runtime.collect { it.name.startsWith('ShrinkItArchive') ? zipTree(it) : 'fake' } }
}
}
}
dependencies {
@ -65,6 +64,18 @@ dependencies {
testCompile "org.apache.commons:commons-lang3:$commonsLang3Version"
}
task mavenJar(type: Jar) {
dependencies {
// Just to pass the compile step; these classes are stripped out below.
compile "org.eclipse.swt:org.eclipse.swt.cocoa.macosx.x86_64:$swtVersion"
}
from(sourceSets.main.output) {
include 'com/webcodepro/applecommander/**'
exclude 'com/webcodepro/applecommander/ui/images/**'
exclude 'com/webcodepro/applecommander/ui/swing/**'
exclude 'com/webcodepro/applecommander/ui/swt/**'
}
}
task acJar(type: Jar) {
dependencies {
// Just to pass the compile step; these classes are stripped out below.
@ -121,9 +132,76 @@ task windowsJar(type: Jar) {
}
}
artifacts {
archives acJar
archives linuxJar
archives macosxJar
archives windowsJar
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives mavenJar, acJar
archives linuxJar, macosxJar, windowsJar
archives javadocJar, sourcesJar
}
signing {
// Only sign if we're uploading...
required { gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
addFilter('AppleCommander') { artifact, file ->
// Note that the other executables all have suffixes which change their name.
return artifact.name == 'AppleCommander' && artifact.ext == 'jar'
}
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
// Only preserve the compile and non-SWT POM dependencies
pom('AppleCommander').whenConfigured { p ->
p.dependencies = p.dependencies.findAll { it.scope == "compile" }
p.dependencies = p.dependencies.findAll { it.groupId != "org.eclipse.swt" }
}
pom('AppleCommander').project {
name archivesBaseName
packaging 'jar'
description 'AppleCommander is a general utility for Apple II disk images.'
url 'https://applecommander.github.io/'
scm {
url 'https://github.com/AppleCommander/AppleCommander'
}
licenses {
license {
name 'The GNU General Public License (GPL) Version 2, June 1991'
url 'https://www.gnu.org/licenses/gpl-2.0.html'
}
}
developers {
developer {
id 'robgreene'
email 'robgreene@gmail.com'
}
}
}
}
}
}

View File

@ -1,10 +1,15 @@
# Universal AppleCommander version number. Used for:
# - Naming JAR file.
# - The build will insert this into a file that is read at run time as well.
version=1.4.0-BETA
version=1.4.0
# Dependency versions
shkVersion=1.1.0
swtVersion=4.6.1
junitVersion=4.12
antVersion=1.8.2
commonsLang3Version=3.7
# Maven Central Repository G and A of GAV coordinate. :-)
group=net.sf.applecommander
archivesBaseName=AppleCommander