Removed Utilities hard dependency. Fixed issue when custom build props are not available

This commit is contained in:
nathan 2018-08-28 01:49:27 +02:00
parent b1db509389
commit 55f6ef3a1e
2 changed files with 43 additions and 84 deletions

View File

@ -19,14 +19,18 @@ import java.time.Instant
buildscript { buildscript {
// load properties from custom location // load properties from custom location
def propsFile = Paths.get("${projectDir}/../../gradle.properties").normalize() def propsFile = Paths.get("${projectDir}/../../gradle.properties").normalize().toFile()
if (propsFile.toFile().canRead()) { if (propsFile.canRead()) {
println("Loading custom property data from: ${propsFile}") println("Loading custom property data from: ${propsFile}")
def props = new Properties() def props = new Properties()
propsFile.withInputStream {props.load(it)} propsFile.withInputStream {props.load(it)}
props.each {key, val -> project.ext.set(key, val)} props.each {key, val -> project.ext.set(key, val)}
} }
else {
ext.sonatypeUsername = ""
ext.sonatypePassword = ""
}
// for plugin publishing and license sources // for plugin publishing and license sources
repositories { repositories {
@ -61,6 +65,8 @@ apply plugin: "com.dorkbox.Licensing"
// give us access to api/implementation differences for building java libraries // give us access to api/implementation differences for building java libraries
apply plugin: 'java-library' apply plugin: 'java-library'
// Utilities project shared configuration
apply from: '../Utilities/scripts/gradle/utilities.gradle'
project.description = 'Unbuffered input and ANSI output support for Linux, MacOS, or Windows for Java 6+' project.description = 'Unbuffered input and ANSI output support for Linux, MacOS, or Windows for Java 6+'
project.group = 'com.dorkbox' project.group = 'com.dorkbox'
@ -118,13 +124,44 @@ licensing {
} }
sourceSets { sourceSets {
utilities {
java {
setSrcDirs Collections.singletonList('../Utilities/src')
include javaFile('dorkbox.util.OS',
'dorkbox.util.OSType',
'dorkbox.util.Property',
'dorkbox.util.FastThreadLocal',
'dorkbox.util.bytes.ByteBuffer2',
'dorkbox.util.jna.JnaHelper',
'dorkbox.util.jna.windows.Kernel32',
'dorkbox.util.jna.windows.structs.CONSOLE_SCREEN_BUFFER_INFO',
'dorkbox.util.jna.windows.structs.INPUT_RECORD',
'dorkbox.util.jna.windows.structs.SMALL_RECT',
'dorkbox.util.jna.windows.structs.COORD',
'dorkbox.util.jna.windows.structs.MOUSE_EVENT_RECORD',
'dorkbox.util.jna.windows.structs.KEY_EVENT_RECORD',
'dorkbox.util.jna.windows.structs.CharUnion',
'dorkbox.util.jna.linux.CLibraryPosix',
'dorkbox.util.jna.linux.structs.Termios')
}
}
main { main {
java { java {
setSrcDirs Collections.singletonList('src') setSrcDirs Collections.singletonList('src')
srcDir utilities.java
} }
} }
} }
project.afterEvaluate {
sourceSets.remove(sourceSets.utilities)
}
repositories { repositories {
mavenLocal() // this must be first! mavenLocal() // this must be first!
@ -133,13 +170,8 @@ repositories {
dependencies { dependencies {
implementation(project('Utilities')) { // utilities dependencies compile only (this is so the IDE can compile the util source)
// don't include any of the project dependencies for anything compileOnly project.ext['utilities']
transitive = false
}
// our main dependencies are ALSO the same as the limited utilities (they are not automatically pulled in from other sourceSets)
// needed by the utilities (custom since we don't want to include everything). IntelliJ includes everything, but our builds do not
api 'net.java.dev.jna:jna:4.5.2' api 'net.java.dev.jna:jna:4.5.2'
api 'net.java.dev.jna:jna-platform:4.5.2' api 'net.java.dev.jna:jna-platform:4.5.2'
@ -147,22 +179,6 @@ dependencies {
api 'org.slf4j:slf4j-api:1.7.25' api 'org.slf4j:slf4j-api:1.7.25'
} }
project('Utilities') {
tasks.withType(Test) {
// want to remove utilities project from unit tests. It's unnecessary to run unit tests for the entire Utilities project
exclude('**/*')
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.incremental = true
// setup compile options. we specifically want to suppress usage of "Unsafe"
options.compilerArgs = ['-XDignore.symbol.file', '-Xlint:deprecation']
}
}
/////////////////////////////// ///////////////////////////////
////// Task defaults ////// Task defaults
/////////////////////////////// ///////////////////////////////
@ -187,49 +203,13 @@ static String[] javaFile(String... fileNames) {
for (name in fileNames) { for (name in fileNames) {
def fixed = name.replace('.', '/') + '.java' def fixed = name.replace('.', '/') + '.java'
fileList.add(fixed) fileList.add('../Utilities/src/' + fixed)
} }
return fileList return fileList
} }
task compileUtils(type: JavaCompile) {
// we don't want the default include of **/*.java
getIncludes().clear()
source = Collections.singletonList('../Utilities/src')
include javaFile('dorkbox.util.OS',
'dorkbox.util.OSType',
'dorkbox.util.Property',
'dorkbox.util.FastThreadLocal',
'dorkbox.util.bytes.ByteBuffer2',
'dorkbox.util.jna.JnaHelper',
'dorkbox.util.jna.windows.Kernel32',
'dorkbox.util.jna.windows.structs.CONSOLE_SCREEN_BUFFER_INFO',
'dorkbox.util.jna.windows.structs.INPUT_RECORD',
'dorkbox.util.jna.windows.structs.SMALL_RECT',
'dorkbox.util.jna.windows.structs.COORD',
'dorkbox.util.jna.windows.structs.MOUSE_EVENT_RECORD',
'dorkbox.util.jna.windows.structs.KEY_EVENT_RECORD',
'dorkbox.util.jna.windows.structs.CharUnion',
'dorkbox.util.jna.linux.CLibraryPosix',
'dorkbox.util.jna.linux.structs.Termios')
classpath = sourceSets.main.compileClasspath
destinationDir = file("$rootDir/build/classes_utilities")
}
///////////////////////////////
////// Jar Tasks
///////////////////////////////
jar {
dependsOn compileUtils
// include applicable class files from subset of Utilities project
from compileUtils.destinationDir
}
///////////////////////////// /////////////////////////////
//// Maven Publishing + Release //// Maven Publishing + Release
@ -262,17 +242,6 @@ publishing {
version project.version version project.version
pom { pom {
withXml {
// eliminate logback and utilities (no need in maven POMs)
def root = asNode()
root.dependencies.'*'.findAll() {
it.artifactId.text() == "Utilities"
}.each() {
it.parent().remove(it)
}
}
name = project.ext.name name = project.ext.name
url = project.ext.url url = project.ext.url
description = project.description description = project.description

View File

@ -13,14 +13,4 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
include("Utilities")
for (project in rootProject.children) {
project.projectDir = file("../$project.name")
project.buildFileName = "build.gradle"
assert (project.projectDir.directory)
assert (project.buildFile.file)
}
enableFeaturePreview('STABLE_PUBLISHING') enableFeaturePreview('STABLE_PUBLISHING')