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

use hale-core libraries and add formatting rules #153

Merged
merged 8 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 118 additions & 95 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
id "nebula.ospackage-application" version "9.1.1"
id 'org.ajoberstar.grgit' version '5.2.2'
id 'to.wetransform.semantic-release-version' version '2.1.1'
id 'com.diffplug.spotless' version '6.25.0'
}

apply plugin: 'org.standardout.eclipseconfig'
Expand All @@ -30,7 +31,7 @@ java {
group = 'to.wetransform'

project.ext {
haleVersion = '5.3.0'
haleVersion = '5.4.0-SNAPSHOT'
groovyVersion = '2.5.23'
}

Expand All @@ -46,7 +47,8 @@ repositories {
// but libs-release-local was placed before snapshots here in the hierarchy and also
// vice-versa case when dependencies were encountered from release but snapshots
// was placed before release
maven { // wetransform release repository (HALE releases and Eclipse dependencies)
maven {
// wetransform release repository (HALE releases and Eclipse dependencies)
url 'https://artifactory.wetransform.to/artifactory/local'
}

Expand All @@ -66,108 +68,53 @@ configurations {
dependencies {
// HALE

// CLI API, utilities and default commands
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.util.cli:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.cli:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.app.cli.commands:$haleVersion"
// BOM
implementation(platform("eu.esdihumboldt.hale:bom:$haleVersion"))

implementation "org.codehaus.groovy:groovy-all:$groovyVersion"
/*
* Features
*/

// core
implementation 'eu.esdihumboldt.unpuzzled:org.eclipse.equinox.nonosgi.registry:1.0.0'
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.core:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.align.groovy:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.align.merge:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.referencing:$haleVersion"

// transformation
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.app.transform:$haleVersion"
// needed to run successfully:
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.headless.orient:$haleVersion" // reiterable transformation sink (for WFS FeatureCollection)
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.propertyaccessor:$haleVersion" // for CQL filters to work
// transformation functions:
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.core:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.inspire:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.geometric:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.groovy:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.groovy.helpers:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.numeric:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.string:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.custom:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.cst.functions.collector:$haleVersion"

// formats
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.xml:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.xsd:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.gml:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.shp:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.csv:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.wfs:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.json:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.xls:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.geopackage:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.html.svg:$haleVersion"

// database support
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.postgresql:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.mssql:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.msaccess:$haleVersion"
// CLI and core hale libraries & resources
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.app.feature.cli:$haleVersion"

// core I/O providers and core hale libraries & resources
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.feature.core:$haleVersion"

// hale connect
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.haleconnect:$haleVersion"
// HTML export
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.feature.html:$haleVersion"

// code list formats
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.codelist.xml:$haleVersion"
/*
* Additional formats
*/

implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.mssql:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.msaccess:$haleVersion"

// Schematron validation
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.schematron:$haleVersion"
// replacement for omitted Saxon dependency
// tested w/ schematron validation in https://github.com/wetransform/exp-schematron/tree/exp/saxon-he
implementation 'net.sf.saxon:Saxon-HE:9.9.1-8'

// converters
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.convert.core:$haleVersion"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.common.convert.wkt:$haleVersion"

// Groovy meta extensions
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.util.groovy.meta.extension:$haleVersion"

// logging
implementation(group: 'eu.esdihumboldt.unpuzzled', name: 'de.fhg.igd.slf4jplus.logback.appender', version: '1.2.0.201503311443')
implementation 'org.slf4j:jul-to-slf4j:1.7.36'

// resource cache
implementation(group: 'eu.esdihumboldt.hale', name: 'eu.esdihumboldt.util.resource', version: haleVersion)
def resourcesGroup = 'to.wetransform.offline-resources'
// OpenGIS schemas, INSPIRE schemas, W3C schemas, etc.
implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.opengis.net', version: '2024.7.31')
implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.inspire', version: '2024.7.31')
implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.portele.de', version: '2024.1.25')
implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.w3.org', version: '2024.1.25')
// INSPIRE code lists and feature concepts
implementation(group: resourcesGroup,
name: 'eu.esdihumboldt.util.resource.codelists.inspire',
version: '2024.7.31')
implementation(group: resourcesGroup,
name: 'eu.esdihumboldt.util.resource.codelists.inspire.accept-xml',
version: '2024.7.31')
implementation(group: resourcesGroup,
name: 'eu.esdihumboldt.util.resource.featureconcepts.inspire',
version: '2024.2.20')
// More resources
implementation(group: resourcesGroup, name: 'eu.esdihumboldt.util.resource.schemas.repository.gdi-de.org', version: '2024.5.23')
/*
* Other
*/

// user / customer specific
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.adv.merge:$haleVersion"

// Groovy
implementation "org.codehaus.groovy:groovy-all:$groovyVersion"

// CLI
implementation 'commons-cli:commons-cli:1.9.0'
// implementation 'commons-cli:commons-cli:1.9.0'
// Groovy Shell
implementation 'jline:jline:2.14.6'

// Testing
/*
* Testing
*/
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
}
Expand All @@ -176,16 +123,23 @@ configurations.all {
// ensure SNAPSHOTs are updated every time if needed
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
def defaultJvmArgs = ['-Dcache.level1.enabled=false',
'-Dcache.level1.size=0',
'-Dcache.level2.enabled=false',
'-Dcache.level2.size=0',
'--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED']
def defaultJvmArgs = [
'-Dcache.level1.enabled=false',
'-Dcache.level1.size=0',
'-Dcache.level2.enabled=false',
'-Dcache.level2.size=0',
'--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED'
]
mainClassName = 'to.wetransform.halecli.CLI'
applicationName = 'hale'
applicationDefaultJvmArgs = defaultJvmArgs

test {
// debug classloading
// jvmArgs '-verbose:class'
}

/*
* plugin.xml and OSGi manifest
*
Expand All @@ -197,7 +151,7 @@ applicationDefaultJvmArgs = defaultJvmArgs
jar {
manifest {
attributes 'Bundle-SymbolicName': 'to.wetransform.halecli;singleton:=true',
'Bundle-Vendor': 'wetransform GmbH'
'Bundle-Vendor': 'wetransform GmbH'
}
}

Expand Down Expand Up @@ -237,10 +191,12 @@ docker {
// switching to jre-jammy as the use pf Alpine as the OS of the hale-cli image breaks derived images that expect Ubuntu
baseImage = 'eclipse-temurin:17-jre-jammy'
maintainer = 'Simon Templer "simon@wetransform.to"'
images = ["wetransform/${project.name}:${project.version}", "wetransform/${project.name}:latest"]
images = [
"wetransform/${project.name}:${project.version}",
"wetransform/${project.name}:latest"
]
// apply JAVA_OPTS to docker plugin as the default args configured in build does not apply to docker plugin
jvmArgs = defaultJvmArgs

}

url = project.hasProperty('dockerHost') ? dockerHost : 'http://localdocker:2375'
Expand All @@ -254,7 +210,7 @@ docker {
}

dockerCreateDockerfile {
def buildTime = java.time.ZonedDateTime.now().format(java.time.format.DateTimeFormatter.ISO_INSTANT);
def buildTime = java.time.ZonedDateTime.now().format(java.time.format.DateTimeFormatter.ISO_INSTANT)
label('git.sha': grgit.head().id, 'git.branch': grgit.branch.current.name, 'build.version': version, 'build.time': buildTime)
instruction 'COPY hale /hale/'
}
Expand Down Expand Up @@ -346,3 +302,70 @@ task uploadArchives {
wrapper {
gradleVersion = '7.6.4'
}

/*
* Formatting
*/

def header = '''
/*
* Copyright (c) $YEAR wetransform GmbH
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution. If not, see <http://www.gnu.org/licenses/>.
*/
'''

// add header only if "@custom-license-header" is NOT present in file
def headerRegex = /^(?s)(?!.*@custom-license-header).*/

spotless {
java {
toggleOffOn()

importOrder('java', 'javax', 'org', 'com', '')

removeUnusedImports()

// https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-jdt
eclipse().configFile('eclipse-format.xml')

licenseHeader(header).onlyIfContentMatches(headerRegex)

trimTrailingWhitespace()
endWithNewline()
}

groovy {
toggleOffOn()

importOrder('groovy', 'java', 'javax', 'org', 'com', '')

// https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-groovy
greclipse().configFile('groovy-format.properties')

// excludes all Java sources within the Groovy source dirs from formatting
excludeJava()

licenseHeader(header).onlyIfContentMatches(headerRegex)

trimTrailingWhitespace()
endWithNewline()
}

groovyGradle {
toggleOffOn()

target '*.gradle'

greclipse().configFile('groovy-format.properties')

trimTrailingWhitespace()
endWithNewline()
}
}
Loading
Loading