Skip to content

Commit

Permalink
[ci] Uses recommended way to create task in build.gradle (#2451)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu committed Mar 9, 2023
1 parent bbd0777 commit abe5d86
Show file tree
Hide file tree
Showing 22 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ allprojects {
apply from: file("${rootProject.projectDir}/../tools/gradle/android-formatter.gradle")
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion android/pytorch-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ afterEvaluate {
}


task processResources {
tasks.register('processResources') {
doLast {
def url = "https://publish.djl.ai/pytorch/${pytorch_version}/jnilib/${djl_version}/android"
def abis = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
Expand Down
2 changes: 1 addition & 1 deletion basicdataset/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
testImplementation project(":engines:pytorch:pytorch-engine")
}

task syncS3(type: Exec) {
tasks.register('syncS3', Exec) {
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read"

standardOutput = new ByteArrayOutputStream()
Expand Down
5 changes: 3 additions & 2 deletions engines/mxnet/mxnet-engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ processResources {
checkstyleMain.source = 'src/main/java'
pmdMain.source = 'src/main/java'

task jnarator(dependsOn: ":engines:mxnet:jnarator:jar") {
tasks.register('jnarator') {
dependsOn ":engines:mxnet:jnarator:jar"
outputs.dir "${project.buildDir}/generated-src"
doLast {
File jnaGenerator = project(":engines:mxnet:jnarator").jar.outputs.files.singleFile
Expand Down Expand Up @@ -72,7 +73,7 @@ def checkForUpdate(String path, String url) {
}
}

task checkHeaderFile() {
tasks.register('checkHeaderFile') {
outputs.files "${project.buildDir}/mxnet_c_api.h", "${project.buildDir}/nnvm_c_api.h"
doFirst {
if (gradle.startParameter.offline) {
Expand Down
2 changes: 1 addition & 1 deletion engines/mxnet/mxnet-model-zoo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
}

task syncS3(type: Exec) {
tasks.register('syncS3', Exec) {
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read"

standardOutput = new ByteArrayOutputStream()
Expand Down
2 changes: 1 addition & 1 deletion engines/mxnet/native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ publishing.repositories {

import java.util.zip.GZIPInputStream

task downloadMxnetNativeLib() {
tasks.register('downloadMxnetNativeLib') {
doLast {
def url = "https://publish.djl.ai/mxnet-${VERSION}"
def files = [
Expand Down
2 changes: 1 addition & 1 deletion engines/paddlepaddle/paddlepaddle-model-zoo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
testRuntimeOnly project(":engines:pytorch:pytorch-jni")
}

task syncS3(type: Exec) {
tasks.register('syncS3', Exec) {
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read"

standardOutput = new ByteArrayOutputStream()
Expand Down
6 changes: 3 additions & 3 deletions engines/paddlepaddle/paddlepaddle-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def downloadBuild(String os, String flavor) {
}
}

task compileJNI {
tasks.register('compileJNI') {
doFirst {
if (System.properties['os.name'].toLowerCase(Locale.ROOT).contains("windows")) {
downloadBuild("win", "cpu")
Expand All @@ -48,7 +48,7 @@ task compileJNI {
}
}

task prepareNativeLibs() {
tasks.register('prepareNativeLibs') {
doLast {
delete "${buildDir}/native"

Expand Down Expand Up @@ -112,7 +112,7 @@ task prepareNativeLibs() {
}
}

task uploadS3 {
tasks.register('uploadS3') {
doLast {
exec {
commandLine "sh", "-c", "find ${buildDir}/native -type f | xargs gzip"
Expand Down
2 changes: 1 addition & 1 deletion engines/pytorch/pytorch-model-zoo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
}

task syncS3(type: Exec) {
tasks.register('syncS3', Exec) {
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read"

standardOutput = new ByteArrayOutputStream()
Expand Down
10 changes: 5 additions & 5 deletions engines/pytorch/pytorch-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ def copyNativeLibToOutputDir(Map<String, String> fileStoreMap, String binaryRoot
}
}

task compileAndroidJNI {
tasks.register('compileAndroidJNI') {
doFirst {
downloadBuildAndroid("${VERSION}")
}
}

task cleanJNI() {
tasks.register('cleanJNI') {
doFirst {
delete "${project.projectDir}/build"
delete "${project.projectDir}/libtorch"
Expand All @@ -180,7 +180,7 @@ task cleanJNI() {
}
}

task compileJNI {
tasks.register('compileJNI') {
doFirst {
// You have to use an environment with CUDA persets for Linux and Windows
if (System.properties['os.name'].toLowerCase(Locale.ROOT).contains("windows")) {
Expand Down Expand Up @@ -260,13 +260,13 @@ publishing.repositories {
}
}

task downloadPyTorchNativeLib() {
tasks.register('downloadPyTorchNativeLib') {
doLast {
prepareNativeLib("${BINARY_ROOT}", "${VERSION}")
}
}

task uploadS3 {
tasks.register('uploadS3') {
doLast {
delete "${BINARY_ROOT}"
prepareNativeLib("${BINARY_ROOT}", "${VERSION}")
Expand Down
2 changes: 1 addition & 1 deletion engines/tensorflow/tensorflow-model-zoo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
}

task syncS3(type: Exec) {
tasks.register('syncS3', Exec) {
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read"

standardOutput = new ByteArrayOutputStream()
Expand Down
4 changes: 2 additions & 2 deletions engines/tensorflow/tensorflow-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies {
download "org.tensorflow:tensorflow-core-api:0.5.0:windows-x86_64-gpu"
}

task uploadTensorflowNativeLibs() {
tasks.register('uploadTensorflowNativeLibs') {
doLast {
delete "${buildDir}/download"
delete "${buildDir}/native"
Expand Down Expand Up @@ -230,7 +230,7 @@ publishing.repositories {

import java.util.zip.GZIPInputStream

task downloadTensorflowNativeLib() {
tasks.register('downloadTensorflowNativeLib') {
doLast {
def url = "https://publish.djl.ai/tensorflow-${tensorflow_version}"
def files = [
Expand Down
2 changes: 1 addition & 1 deletion engines/tensorrt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def buildJNI(String os) {
}
}

task compileJNI {
tasks.register('compileJNI') {
doFirst {
if (System.properties['os.name'].startsWith("Linux")) {
buildJNI("linux")
Expand Down
4 changes: 2 additions & 2 deletions engines/tflite/tflite-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ def downloadJni(String dir) {
}
}

task downloadTfliteNativeLib() {
tasks.register('downloadTfliteNativeLib') {
doLast {
delete "${BINARY_ROOT}"
downloadJni("${BINARY_ROOT}")
}
}

task uploadS3 {
tasks.register('uploadS3') {
doLast {
delete "${BINARY_ROOT}"
downloadJni("${BINARY_ROOT}")
Expand Down
2 changes: 1 addition & 1 deletion examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ run {
systemProperty("file.encoding", "UTF-8")
}

task listmodels(type: JavaExec) {
tasks.register('listmodels', JavaExec) {
systemProperties System.getProperties()
systemProperties.remove("user.dir")
systemProperty("file.encoding", "UTF-8")
Expand Down
2 changes: 1 addition & 1 deletion extensions/fasttext/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ publishing {

apply from: file("${rootProject.projectDir}/tools/gradle/cpp-formatter.gradle")

task compileJNI {
tasks.register('compileJNI') {
doFirst {
if (System.properties['os.name'].toLowerCase(Locale.ROOT).contains("mac")
|| System.properties['os.name'].toLowerCase(Locale.ROOT).contains("linux")) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/sentencepiece/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ publishing {

apply from: file("${rootProject.projectDir}/tools/gradle/cpp-formatter.gradle")

task compileJNI {
tasks.register('compileJNI') {
doFirst {
if (System.properties['os.name'].toLowerCase(Locale.ROOT).contains("win")) {
exec {
Expand Down
2 changes: 1 addition & 1 deletion extensions/spark/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ compileScala {
scalaCompileOptions.setAdditionalParameters(["-target:jvm-1.8"])
}

task formatPython {
tasks.register('formatPython') {
doFirst {
exec {
commandLine "bash", "-c", "find . -name '*.py' -print0 | xargs -0 yapf --in-place"
Expand Down
4 changes: 2 additions & 2 deletions extensions/tokenizers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ publishing {

apply from: file("${rootProject.projectDir}/tools/gradle/cpp-formatter.gradle")

task compileJNI {
tasks.register('compileJNI') {
doFirst {
if (System.properties['os.name'].toLowerCase(Locale.ROOT).contains("mac")
|| System.properties['os.name'].toLowerCase(Locale.ROOT).contains("linux")) {
Expand All @@ -108,7 +108,7 @@ task compileJNI {
}
}

task formatPython {
tasks.register('formatPython') {
doFirst {
exec {
commandLine "bash", "-c", "find . -name '*.py' -print0 | xargs -0 yapf --in-place"
Expand Down
4 changes: 2 additions & 2 deletions integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ java {
}
}

task copyDependencies(type: Copy) {
tasks.register('copyDependencies', Copy) {
into "build/dependencies"
from configurations.runtimeClasspath
}
Expand All @@ -50,7 +50,7 @@ run {
jvmArgs "-Xverify:none"
}

task debugEnv(type: JavaExec) {
tasks.register('debugEnv', JavaExec) {
classpath = sourceSets.main.runtimeClasspath
systemProperties System.getProperties()
systemProperties.remove("user.dir")
Expand Down
2 changes: 1 addition & 1 deletion model-zoo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
testImplementation "org.slf4j:slf4j-simple:${slf4j_version}"
}

task syncS3(type: Exec) {
tasks.register('syncS3', Exec) {
commandLine "sh", "-c", "find . -name .DS_Store | xargs rm && aws s3 sync src/test/resources/mlrepo s3://djl-ai/mlrepo --acl public-read"

standardOutput = new ByteArrayOutputStream()
Expand Down
8 changes: 4 additions & 4 deletions tools/gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
task release {
tasks.register('release') {
doLast {
def collection = fileTree("jupyter").filter { it.name.endsWith(".ipynb") }
collection += files("examples/build.gradle", "examples/pom.xml")
Expand All @@ -8,7 +8,7 @@ task release {
}
}

task staging() {
tasks.register('staging') {
doLast {
if (!project.hasProperty("stagingRepo")) {
throw new GradleException("stagingRepo property is required.")
Expand All @@ -26,7 +26,7 @@ task staging() {
}
}

task increaseBuildVersion {
tasks.register('increaseBuildVersion') {
doLast {
if (!project.hasProperty("targetVersion")) {
throw new GradleException("targetVersion property is required.")
Expand All @@ -48,7 +48,7 @@ task increaseBuildVersion {
}
}

task increaseFinalVersion {
tasks.register('increaseFinalVersion') {
doLast {
if (!project.hasProperty("previousVersion")) {
throw new GradleException("previousVersion property is required.")
Expand Down

0 comments on commit abe5d86

Please sign in to comment.