Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle enhancements #8

Merged
merged 12 commits into from
Nov 30, 2023
49 changes: 22 additions & 27 deletions Android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
//name = 'Better London Travel Android App'
apply plugin: 'net.twisterrob.gradle.plugin.android-app'
apply plugin: 'com.android.application'

repositories {
maven {
name = "jitpack.io"
url = uri("https://jitpack.io/")
content {
includeModule("com.github.martin-stone", "hsv-alpha-color-picker-android")
}
}
//name = "Better London Travel Android App"
plugins {
id("net.twisterrob.blt.convention")
id("net.twisterrob.gradle.plugin.android-app")
id("com.android.application")
}

dependencies {
Expand All @@ -23,15 +16,15 @@ dependencies {
implementation("net.twisterrob.lib:twister-lib-android-color_picker")
implementation("net.twisterrob.lib:twister-lib-android-settings")

implementation(project(':Shared')) {
exclude module: 'android-polyfill'
implementation(projects.shared) {
exclude module: "android-polyfill"
}
implementation("com.google.android.gms:play-services-maps:${VERSION_MAPS}")
implementation("com.google.android.gms:play-services-places:${VERSION_MAPS}")
implementation("com.google.code.findbugs:jsr305:${VERSION_JSR305}")
implementation("com.github.bumptech.glide:glide:${VERSION_GLIDE}")
implementation(libs.gms.maps)
implementation(libs.gms.places)
implementation(libs.jsr305)
implementation(libs.glide)

apply from: "${rootDir}/gradle/testCompile.gradle", to: project
testImplementation(projects.shared.testHelpers)
}

android {
Expand All @@ -51,7 +44,7 @@ android {
}
debug {
// twister-lib-android only has release build type
matchingFallbacks = ['release']
matchingFallbacks = [ "release" ]
}
}
buildFeatures {
Expand All @@ -62,30 +55,32 @@ android {
checkDependencies = true
abortOnError = false
lintConfig = file("lint.xml")
baseline file("lint-baseline.xml")
baseline = file("lint-baseline.xml")
}
flavorDimensions += "app-build"
productFlavors {
full {
// default
applicationId = 'net.twisterrob.blt'
dimension "app-build"
applicationId = "net.twisterrob.blt"
dimension("app-build")
}
range {
applicationId = 'net.twisterrob.blt.range'
dimension "app-build"
applicationId = "net.twisterrob.blt.range"
dimension("app-build")
}
}
}

abstract class GenerateDatabase extends Copy {

@Internal("An intermediate property to satisfy AGP, tracked in destination.")
abstract DirectoryProperty getOutput()
}

def generateDataBase = tasks.register("generateDataBase", GenerateDatabase.class) {
dependsOn(":Data:runNetwork", ":Data:runPostCode")
from(new File(project(':Data').projectDir, 'output')) {
include '*.data.*.sql'
from(new File(projects.data.dependencyProject.projectDir, "output")) {
include("*.data.*.sql")
}
into(output)
}
Expand Down
57 changes: 25 additions & 32 deletions AppEngine/build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,36 @@
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform

apply plugin: 'java'
apply plugin: 'io.micronaut.minimal.application'
apply plugin: 'com.google.cloud.tools.appengine-appyaml'
apply plugin: 'idea'
plugins {
id("net.twisterrob.blt.convention")
id("org.gradle.java")
id("io.micronaut.minimal.application")
id("com.google.cloud.tools.appengine-appyaml")
id("org.gradle.idea")
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = libs.versions.java.appengine.get()
targetCompatibility = libs.versions.java.appengine.get()
}

dependencies {
implementation("com.google.appengine:appengine-api-1.0-sdk:2.0.12")
implementation(platform("com.google.cloud:libraries-bom:${VERSION_GCLOUD}"))
implementation("com.google.cloud:google-cloud-datastore")

runtimeOnly("org.yaml:snakeyaml")
runtimeOnly("io.micronaut.serde:micronaut-serde-jackson")
implementation("io.micronaut.views:micronaut-views-handlebars")
implementation(libs.appengine.api)
implementation(platform(libs.google.cloud))
implementation(libs.google.cloud.datastore)

implementation project(':Shared')
runtimeOnly(libs.snakeyaml)
runtimeOnly(libs.micronaut.jackson)
implementation(libs.micronaut.handlebars)

implementation("org.slf4j:slf4j-api:${VERSION_SLF4J}")
runtimeOnly("org.apache.logging.log4j:log4j-slf4j2-impl:${VERSION_LOG4J}")
// for org.apache.tools.ant.filters.StringInputStream
implementation("ant:ant:1.6.5")
implementation(projects.shared)
implementation(projects.shared.diff)

apply from: "${rootDir}/gradle/testCompile.gradle", to: project
testImplementation("io.micronaut:micronaut-http-client")
testImplementation("com.github.jtidy:jtidy:${VERSION_JTIDY}")
}
implementation(libs.slf4j.api)
runtimeOnly(libs.log4j.slf4j2)

sourceSets {
main {
java.srcDir 'src/main/diff'
}
test {
java.srcDir 'src/test/diff'
}
testImplementation(projects.shared.testHelpers)
testImplementation(libs.micronaut.httpClient)
testImplementation(libs.jtidy)
}

//noinspection UnnecessaryQualifiedReference
Expand All @@ -59,18 +52,18 @@ appengine { com.google.cloud.tools.gradle.appengine.appyaml.AppEngineAppYamlExte
}
tools {
System.getenv("GCLOUD_HOME")?.tap { cloudSdkHome = it }
cloudSdkVersion = VERSION_GCLOUD_SDK as String
cloudSdkVersion = libs.versions.google.cloud.sdk.get()
// https://cloud.google.com/sdk/gcloud/reference#--verbosity
verbosity = "info"
}
}

application {
mainClass.set("net.twisterrob.blt.gapp.Application")
mainClass = "net.twisterrob.blt.gapp.Application"
}

micronaut {
version = VERSION_MICRONAUT as String
version = libs.versions.micronaut.asProvider().get()
runtime("jetty")
testRuntime("junit4")
processing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import io.micronaut.views.View;
import jakarta.servlet.http.*;

import org.apache.tools.ant.filters.StringInputStream;

import com.google.cloud.datastore.*;
import com.google.cloud.datastore.StructuredQuery.OrderBy;

Expand Down Expand Up @@ -95,7 +93,7 @@ private static Result toResult(BaseEntity<?> entry) {
if (content != null) {
try {
Feed feed = Feed.valueOf(entry.getKey().getKind());
InputStream stream = new StringInputStream(content, ENCODING);
InputStream stream = new ByteArrayInputStream(content.getBytes(ENCODING));
@SuppressWarnings({"RedundantTypeArguments", "RedundantSuppression"}) // False positive.
LineStatusFeed feedContents = feed.<LineStatusFeed>getHandler().parse(stream);
result = new Result(date, feedContents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import java.util.*;

import name.fraser.neil.plaintext.diff_match_patch;
import name.fraser.neil.plaintext.diff_match_patch.Diff;

import net.twisterrob.blt.diff.HtmlDiff;
import net.twisterrob.blt.io.feeds.trackernet.model.LineStatus;
import net.twisterrob.blt.model.Line;

Expand Down Expand Up @@ -107,10 +105,7 @@ protected void diffDesc(Line line, LineStatus oldStatus, LineStatus newStatus) {
}

private static String diffDesc(String oldDesc, String newDesc) {
diff_match_patch differ = new diff_match_patch();
LinkedList<Diff> diff = differ.diff_main(oldDesc, newDesc);
differ.diff_cleanupSemantic(diff);
return differ.diff_prettyHtml(diff);
return new HtmlDiff().diff(oldDesc, newDesc);
}

protected void diffError() {
Expand Down
78 changes: 44 additions & 34 deletions Data/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
// name = 'twister-travel-data'
version = '0.0.1-SNAPSHOT'
plugins {
id("net.twisterrob.blt.convention")
id("org.gradle.java-library")
id("net.twisterrob.gradle.plugin.java")
id("org.gretty")
id("org.gradle.idea")
}

java {
sourceCompatibility = libs.versions.java.asProvider().get()
targetCompatibility = libs.versions.java.asProvider().get()
}

// name = "twister-travel-data"
version = "0.0.1-SNAPSHOT"
// <name>Better London Travel Data Generation</name>
// <description>Standalone project to handle large feeds</description>

apply plugin: 'java-library'
apply plugin: 'net.twisterrob.gradle.plugin.java'

dependencies {
//configurations.implementation.resolutionStrategy.cacheChangingModulesFor 0, 'seconds' // -SNAPSHOT
api project(':Shared')
implementation("com.google.code.findbugs:jsr305:${VERSION_JSR305}")
implementation("org.slf4j:slf4j-api:${VERSION_SLF4J}")
runtimeOnly "org.slf4j:slf4j-simple:${VERSION_SLF4J}"
implementation 'org.xerial:sqlite-jdbc:3.7.15-M1'
api(projects.shared)
implementation(libs.jsr305)
implementation(libs.slf4j.api)
implementation(libs.slf4j.simple)
implementation(libs.sqlite.jdbc)

apply from: "${rootDir}/gradle/testCompile.gradle", to: project
testImplementation(projects.shared.testHelpers)
}

apply plugin: 'org.gretty'
// TODO logging doesn't work with org.eclipse nor org.mortbay package names
// -Dorg.mortbay.log.class=org.eclipse.jetty.util.log.StrErrLog changes the logger, but no output
// --debug logs, but too much and not configurable
gretty { // org.akhikhl.gretty.GrettyExtension
//daemon = true
extraResourceBase(file('src/data'))
extraResourceBase(file("src/data"))

// + Magic @Delegate org.akhikhl.gretty.ServerConfig through GrettyExtension implements GrettyConfig
httpPort = 8081
Expand All @@ -33,44 +41,46 @@ gretty { // org.akhikhl.gretty.GrettyExtension
// + Magic @Delegate org.akhikhl.gretty.WebAppConfig through GrettyExtension implements GrettyConfig
}

apply plugin: 'idea'
idea {
module {
excludeDirs = [ file('output'), file('src/data') ]
excludeDirs = [
file("output"),
file("src/data"),
]
}
}

task runNetwork(type: JavaExec) {
def inputDir = '../temp/feed15/LULDLRRiverTramCable'
def outputDir = 'output';
inputs.dir inputDir
inputs.dir 'src/data/PredictionSummary'
outputs.dir outputDir
tasks.register("runNetwork", JavaExec.class) {
def inputDir = "../temp/feed15/LULDLRRiverTramCable"
def outputDir = "output"
inputs.dir(inputDir).withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/data/PredictionSummary")
outputs.dir(outputDir)
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
mainClass = 'net.twisterrob.blt.data.apps.TravelNetworkParser'
mainClass = "net.twisterrob.blt.data.apps.TravelNetworkParser"
args = [ inputDir, outputDir ]
enableAssertions = true
}

task runPostCode(type: JavaExec) {
def inputDir = '../temp/feed15/LULDLRRiverTramCable'
def outputFile = 'output/LondonTravel.data.AreaHull.sql';
inputs.dir inputDir
outputs.file outputFile
tasks.register("runPostCode", JavaExec.class) {
def inputDir = "../temp/feed15/LULDLRRiverTramCable"
def outputFile = "output/LondonTravel.data.AreaHull.sql"
inputs.dir(inputDir).withPathSensitivity(PathSensitivity.RELATIVE)
outputs.file(outputFile)
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
mainClass = 'net.twisterrob.blt.data.apps.PostCodeAreas'
mainClass = "net.twisterrob.blt.data.apps.PostCodeAreas"
enableAssertions = true
}

task runDisplay(type: JavaExec) {
tasks.register("runDisplay", JavaExec.class) {
group = ApplicationPlugin.APPLICATION_GROUP
classpath = sourceSets.main.runtimeClasspath
mainClass = 'net.twisterrob.blt.data.apps.DisplayLine'
args = [ 'DLR' ]
if (project.hasProperty('lines')) {
args = project.property('lines').toString().split(',') as List;
mainClass = "net.twisterrob.blt.data.apps.DisplayLine"
args = [ "DLR" ]
if (project.hasProperty("lines")) {
args = project.property("lines").toString().split(",") as List
}
enableAssertions = true
}
12 changes: 8 additions & 4 deletions Shared/android-polyfill/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
apply plugin: 'net.twisterrob.gradle.plugin.java'
plugins {
id("net.twisterrob.blt.convention")
id("org.gradle.java")
id("net.twisterrob.gradle.plugin.java")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = libs.versions.java.asProvider().get()
targetCompatibility = libs.versions.java.asProvider().get()
}

dependencies {
implementation 'net.sf.kxml:kxml2:2.3.0'
implementation(libs.kxml2)
}
29 changes: 16 additions & 13 deletions Shared/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
apply plugin: 'java-library'
apply plugin: 'net.twisterrob.gradle.plugin.java'
plugins {
id("net.twisterrob.blt.convention")
id("org.gradle.java-library")
id("net.twisterrob.gradle.plugin.java")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = libs.versions.java.asProvider().get()
targetCompatibility = libs.versions.java.asProvider().get()
}

// <name>Better London Travel Shared</name>
// <description>Shared model and surrounding classes</description>
//name = 'twister-travel-shared'
version = '0.0.1-SNAPSHOT'
//name = "twister-travel-shared"
version = "0.0.1-SNAPSHOT"
dependencies {
api('net.twisterrob.lib:twister-lib-general')
api('net.twisterrob.lib:twister-lib-core')
api("net.twisterrob.lib:twister-lib-general")
api("net.twisterrob.lib:twister-lib-core")

implementation("com.google.code.findbugs:jsr305:${VERSION_JSR305}")
implementation("org.slf4j:slf4j-api:${VERSION_SLF4J}")
implementation project(':Shared:android-polyfill')
implementation('net.twisterrob.lib:twister-lib-java_desktop')
implementation(libs.jsr305)
implementation(libs.slf4j.api)
implementation(projects.shared.androidPolyfill)
implementation("net.twisterrob.lib:twister-lib-java_desktop")

apply from: "${rootDir}/gradle/testCompile.gradle", to: project
testImplementation(projects.shared.testHelpers)
}
Loading