Skip to content

Instantly share code, notes, and snippets.

@akbertram
Created April 26, 2023 04:46
Show Gist options
  • Save akbertram/1d543c8648ddf322f9866c373877b04f to your computer and use it in GitHub Desktop.
Save akbertram/1d543c8648ddf322f9866c373877b04f to your computer and use it in GitHub Desktop.
Custom gradle example
description = 'ActivityInfo Internationalization Resources'
// Define an addition 'tool' source set that includes
// the java code to verify i18n resources and merge
// translations from PoEditor at build time
sourceSets {
tool {
java {
srcDir 'src/tool/java'
compileClasspath += main.output
runtimeClasspath += main.output
}
resources {
srcDir 'src/tool/resources'
}
}
}
dependencies {
compile libraries.guava
compile libraries.gwt.i18nServer
compileOnly libraries.gwt.user
toolCompile libraries.jersey.client
toolCompile libraries.jersey.json
toolCompile libraries.jersey.multipart
toolCompile libraries.jersey.hk2
toolCompile libraries.guava
toolCompile libraries.gwt.servlet
toolCompile 'com.github.javaparser:javaparser-core:2.0.0'
}
jar {
from project.sourceSets.main.allSource
from project.sourceSets.main.output
}
task checkMessages(type: JavaExec) {
group = "Verification"
description = 'Checks localization resources'
dependsOn 'toolClasses'
inputs.dir 'src/main/java'
inputs.dir 'src/main/resources'
outputs.upToDateWhen { true }
main = 'org.activityinfo.i18n.tools.Check'
classpath = sourceSets.tool.runtimeClasspath
workingDir = projectDir
}
test.dependsOn checkMessages
task pullTranslations(type: JavaExec) {
group = "I18N"
description = 'Fetches translations from PoEditor.com'
dependsOn 'toolClasses'
finalizedBy 'licenseFormat'
main = 'org.activityinfo.i18n.tools.Pull'
classpath = sourceSets.tool.runtimeClasspath
workingDir = projectDir
doFirst {
if(project.hasProperty('poApiKey')) {
environment 'PO_API_KEY', project.property('poApiKey')
}
}
}
task pushTranslations(type: JavaExec) {
group = "I18N"
description = 'Pushes new translation keys to PoEditor.com'
dependsOn 'toolClasses'
main = 'org.activityinfo.i18n.tools.Push'
classpath = sourceSets.tool.runtimeClasspath
workingDir = projectDir
doFirst {
if(project.hasProperty('poApiKey')) {
environment 'PO_API_KEY', project.property('poApiKey')
}
if(project.hasProperty("dryRun")) {
args 'dryRun'
}
}
}
task purgeUnused(type: JavaExec) {
group = "I18N"
description = 'Deletes unused translations from PoEditor.com '
dependsOn 'toolClasses'
main = 'org.activityinfo.i18n.tools.Push'
args 'purge'
classpath = sourceSets.tool.runtimeClasspath
workingDir = projectDir
doFirst {
if(project.hasProperty('poApiKey')) {
environment 'PO_API_KEY', project.property('poApiKey')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment