diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..975d2f7 --- /dev/null +++ b/build.gradle @@ -0,0 +1,241 @@ +plugins { + id 'java' + id 'groovy' +} + +defaultTasks 'main' + +version = providers.gradleProperty('version').getOrElse('dev') + +ext { + pluginName = 'Hadoop-UCD' + + releasesDir = file("$projectDir/releases") + libDir = file("$projectDir/lib") + + libBuildDir = file("$projectDir/lib/build") + libTestDir = file("$projectDir/lib/test") + + libBuildClassesDir = file("$projectDir/lib/build/classes") + buildJavaDir = file("$buildDir/java") + buildPluginDir = file("$buildDir/plugin") + + libTestJavaDir = file("$projectDir/lib/test/java") +} + +repositories { + mavenCentral() +} + +configurations { + buildConf + testConf +} + +dependencies { + buildConf 'org.codehaus.groovy:groovy-all:1.8.8' + + testImplementation 'junit:junit:4.13.2' + testImplementation 'org.hamcrest:hamcrest-core:1.3' + + testConf 'junit:junit:4.13.2' + testConf 'org.hamcrest:hamcrest-core:1.3' +} + +sourceSets { + main { + java.srcDirs = ['src/main/java'] + groovy.srcDirs = ['src/main/groovy'] + } + + test { + java.srcDirs = ['src/test/java'] + groovy.srcDirs = ['src/test/groovy'] + } +} + +tasks.register('main') { + dependsOn 'cleanBuild', 'resolve', 'compileClasses', 'buildPlugin', 'dist', 'runTests' + doLast { + println 'Plugin build complete!' + } +} + +tasks.register('cleanBuild') { + description 'Clean build directory, releases directory, and lib directory' + delete buildDir + delete releasesDir + delete libDir + + doLast { + mkdir buildDir + } +} + +tasks.register('resolve') { + dependsOn 'cleanBuild' + + doFirst { + mkdir libDir + mkdir libBuildDir + mkdir libTestDir + } + + doLast { + copy { + from configurations.runtimeClasspath + into libDir + } + + copy { + from configurations.buildConf + into libBuildDir + } + + copy { + from configurations.testConf + into libTestDir + } + } +} + +tasks.register('compileClasses') { + + dependsOn 'resolve', 'compileJava', 'compileGroovy' + + doLast { + + mkdir libBuildClassesDir + mkdir buildJavaDir + + copy { + from sourceSets.main.output.classesDirs + into libBuildClassesDir + } + + copy { + from('src/main/java') { + include '**/*.properties' + } + into libBuildClassesDir + } + + copy { + from 'src/main/java/com/ibm/rational/deploy/Hadoop/messages.properties' + into "$libBuildClassesDir/com/ibm/rational/deploy/Hadoop" + } + + println 'Classes compiled successfully' + } +} + +tasks.register('buildPlugin') { + + dependsOn 'resolve', 'createHadoopJar' + + doLast { + + mkdir buildPluginDir + + copy { + from('plugin') { + include 'info.xml' + include 'upgrade.xml' + include 'plugin.xml' + } + + into buildPluginDir + } + + copy { + from 'src/main/scripts' + into "$buildPluginDir/bin" + } + + copy { + from('license') { + include 'EPL.txt' + include 'DCO1.1.txt' + } + into "$buildPluginDir/license" + } + + copy { + from('doc') { + include 'HowTo.html' + include '*.docx' + } + into "$buildPluginDir/doc" + } + + copy { + from('lib') { + exclude '**/build/**' + exclude '**/test/**' + } + into "$buildPluginDir/lib" + } + + copy { + from('src/main/groovy') { + include '**/*.groovy' + } + into "$buildPluginDir/classes" + } + + copy { + from("$buildDir/java/hadoop.jar") + into "$buildPluginDir/java" + } + } +} + +tasks.register('createHadoopJar', Jar) { + + dependsOn 'compileClasses' + + archiveFileName = 'hadoop.jar' + destinationDirectory = buildJavaDir + + from libBuildClassesDir +} + +tasks.register('dist', Zip) { + description = 'Create distribution zip' + dependsOn 'resolve', 'buildPlugin' + archiveFileName = "${pluginName}-v${version}.zip" + destinationDirectory = releasesDir + from buildPluginDir + doLast { + println '[zip] Building zip: ' + file("$releasesDir/${pluginName}-v${version}.zip") + } +} + +tasks.register('runTests') { + description = 'Compile and run JUnit tests ()' + dependsOn 'compileTests', 'test' +} + +tasks.register('compileTests') { + description = 'Compile test Java classes (equivalent to Ant compile-tests)' + dependsOn 'compileClasses', 'compileTestJava' +} + +test { + useJUnit() + + reports { + junitXml.required = true + html.required = true + + junitXml.outputLocation = layout.projectDirectory.dir("releases/report/xml") + html.outputLocation = layout.projectDirectory.dir("releases/report/html") + } + + testLogging { + events "passed", "failed", "skipped" + } +} + + + diff --git a/build.xml b/build.xml deleted file mode 100644 index d44c9c6..0000000 --- a/build.xml +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Plugin build complete! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8bdaf60 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2a84e18 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..7877f84 --- /dev/null +++ b/gradlew @@ -0,0 +1,125 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by "Gradle init" +# +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( absolute + *) app_path=$APP_HOME$link ;; #( relative + esac +done + +# This is reliable cross-platform. +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + ;; + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$@" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/ivy.xml b/ivy.xml deleted file mode 100644 index e995598..0000000 --- a/ivy.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/ivysettings.xml b/ivysettings.xml deleted file mode 100644 index 10c8182..0000000 --- a/ivysettings.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..bf20184 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'Hadoop-UCD'