diff --git a/.classpath b/.classpath deleted file mode 100644 index 5da62d4..0000000 --- a/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.gitignore b/.gitignore index 5050a82..9515ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ /.idea /out *.iml +.classpath +.project \ No newline at end of file diff --git a/.project b/.project deleted file mode 100644 index afbd5e8..0000000 --- a/.project +++ /dev/null @@ -1,19 +0,0 @@ - - - gradle-ikvm-plugin - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.springsource.ide.eclipse.gradle.core.nature - org.eclipse.jdt.core.javanature - org.eclipse.jdt.groovy.core.groovyNature - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2e081..95d181d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Gradle IKVM plugin ChangeLog +## 2.10 +* gradle 5.0 support +* built by gradle 5.4.1 +* minimum requirement of jdk is now 1.8 +* remove unnecessary dependencies + ## 2.9 ### Added diff --git a/build.gradle b/build.gradle index 8c067e6..68f33a1 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ plugins { - id "nu.studer.plugindev" version "1.0.3" + id "nu.studer.plugindev" version "1.0.12" id "com.ullink.functions" version "1.0" - id "com.jfrog.bintray" version "1.2" - id 'net.researchgate.release' version '2.3.4' + id "com.jfrog.bintray" version "1.8.4" + id 'net.researchgate.release' version '2.8.0' } apply plugin: 'groovy' @@ -10,15 +10,11 @@ apply plugin: 'groovy' group = 'com.ullink.gradle' description 'gradle-ikvm-plugin is a Gradle plugin for IKVM artifact compilation' -sourceCompatibility = 1.6 +sourceCompatibility = 1.8 dependencies { - compile fileTree(dir: "${gradle.gradleHomeDir}/lib/plugins", include: "gradle-plugins-*.jar") compile getTools() - compile 'org.apache.commons:commons-lang3:3.4' - compile 'commons-io:commons-io:2.5' - compile 'commons-codec:commons-codec:1.10' - testCompile 'junit:junit:4.8.2' + testCompile 'junit:junit:4.12' } bintray { @@ -45,12 +41,4 @@ plugindev { done() } -if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } -} - project.tasks.afterReleaseBuild.dependsOn project.tasks.bintrayUpload diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 3baa851..5c2d1cf 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 461bbf0..ee69dd6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sat Dec 27 15:48:48 CET 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/gradlew b/gradlew index 27309d9..b0d6d0a 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,20 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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 +# +# http://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. +# ############################################################################## ## @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$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="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -154,11 +170,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# 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 "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 832fdb6..9991c50 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@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 http://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 @@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @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= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -49,7 +65,6 @@ goto fail @rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +75,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line diff --git a/src/main/groovy/com/ullink/Ikvm.groovy b/src/main/groovy/com/ullink/Ikvm.groovy index 2b42601..377ea88 100644 --- a/src/main/groovy/com/ullink/Ikvm.groovy +++ b/src/main/groovy/com/ullink/Ikvm.groovy @@ -1,26 +1,29 @@ package com.ullink -import org.apache.commons.codec.digest.DigestUtils -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.internal.ConventionTask -import org.gradle.api.tasks.InputFile +import org.gradle.api.DefaultTask +import org.gradle.api.artifacts.Configuration +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.RegularFile +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction -import org.gradle.api.tasks.bundling.Jar import org.gradle.internal.os.OperatingSystem +import org.gradle.jvm.tasks.Jar -class Ikvm extends ConventionTask { +import java.nio.file.Files + +class Ikvm extends DefaultTask { public static final String IKVM_EXE = 'bin/ikvmc.exe' - def ikvmHome - def ikvmVersion - def destinationDir - String assemblyName + + Property ikvmHome + Property ikvmVersion + DirectoryProperty destinationDir + Property assemblyName boolean debug = true def keyFile - String version + Property version String fileVersion def srcPath boolean removeAssertions = true @@ -37,42 +40,51 @@ class Ikvm extends ConventionTask { def warnAsError @InputFiles - def jars + ListProperty jars Ikvm() { - conventionMapping.map "destinationDir", { project.jar.destinationDir } - conventionMapping.map "jars", { [ project.jar.archivePath ] } - conventionMapping.map "assemblyName", { project.name } - conventionMapping.map "version", { project.version } - outputs.files { - if (generateDoc) { - return project.tasks.ikvmDoc.getDestinationFile() - } - } - outputs.files { - if (debug) { - getDestinationDebugFile() - } - } + ikvmHome = project.objects.property(String) + ikvmVersion = project.objects.property(String) + destinationDir = project.objects.directoryProperty() + jars = project.objects.listProperty(RegularFile) + assemblyName = project.objects.property(String) + version = project.objects.property(String) + + def jarTask = (Jar)project.jar + destinationDir.convention(jarTask.destinationDirectory) + jars.convention(project.provider { [ jarTask.archiveFile.get() ] }) + assemblyName.convention(project.name) + version.convention(project.version) + project.afterEvaluate { - def src = getJars() - project.tasks.withType(Jar.class).matching { - src.contains(it.archivePath) + def src = jars.get() + project.tasks.withType(Jar).find { + src.contains(it.archiveFile.get()) }.each { dependsOn it } + if (generateDoc) { + outputs.files { + return project.tasks.ikvmDoc.getDestinationFile() + } + } + if (debug) { + outputs.files { + getDestinationDebugFile() + } + } } - - Configuration compileConfiguration = (Configuration)project.configurations.findByName(getCompileConfigurationName()); + + Configuration compileConfiguration = (Configuration) project.configurations.findByName(getCompileConfigurationName()) if (compileConfiguration == null) { - compileConfiguration = project.configurations.maybeCreate(getCompileConfigurationName()); + compileConfiguration = project.configurations.maybeCreate(getCompileConfigurationName()) } compileConfiguration.transitive = true compileConfiguration.description = this.name + ' compile classpath' } String getCompileConfigurationName() { - return StringUtils.uncapitalize(String.format("%sCompile", this.name )); + String.format("%sCompile", this.name).toLowerCase() } def getIkvmc(){ @@ -95,7 +107,7 @@ class Ikvm extends ConventionTask { if (!dest.exists()) { dest.mkdirs() } - def urlSha1 = DigestUtils.shaHex(url.toString()) + def urlSha1 = url.toString().digest('SHA-1') def ret = new File(dest, urlSha1) if (!ret.exists()) { project.logger.info "Downloading & Unpacking Ikvm ${url}" @@ -115,10 +127,10 @@ class Ikvm extends ConventionTask { assert sub, "${IKVM_EXE} not found in downloaded archive" return sub } - return project.file(home); + return project.file(home) } - def ikvmcOptionalOnMono(){ + def ikvmcOptionalOnMono (){ if (!OperatingSystem.current().windows){ project.logger.info "Using Mono for IKVM" return ["mono",getIkvmc()] @@ -141,11 +153,11 @@ class Ikvm extends ConventionTask { } def getDestDir() { - project.file(getDestinationDir()) + project.file(destinationDir.get()) } def getDestinationDebugFile() { - return new File(getDestDir(), getAssemblyName() + ".pdb") + return new File(getDestDir(), assemblyName.get() + ".pdb") } @OutputFile @@ -157,18 +169,18 @@ class Ikvm extends ConventionTask { { case "library": extension = ".dll" - break; + break case "module": extension = ".netmodule" - break; + break case "exe": case "winexe": default: extension = ".exe" - break; + break } } - new File(getDestDir(), getAssemblyName() + extension) + new File(getDestDir(), assemblyName.get() + extension) } def getCommandLineArgs() { @@ -177,7 +189,7 @@ class Ikvm extends ConventionTask { def destFile = getDestFile() commandLineArgs += "-out:${destFile}" - def version = getVersion().replaceAll("[^0-9.]+", "") + def version = version.get().replaceAll("[^0-9.]+", "") commandLineArgs += "-version:${version}" if (fileVersion) { @@ -237,26 +249,26 @@ class Ikvm extends ConventionTask { commandLineArgs += "-warnaserror" } - commandLineArgs += getJars() + commandLineArgs += jars.get().collect { it.asFile.path } commandLineArgs += getReferences().collect{"-reference:${it}"} - return commandLineArgs; + return commandLineArgs } @TaskAction def build() { File debugFile = getDestinationDebugFile() if (debug && debugFile.isFile()) { - debugFile.delete(); + debugFile.delete() } project.exec { - commandLine = commandLineArgs + commandLine(commandLineArgs) } if (debug && !debugFile.isFile()) { // bug in IKVM 0.40 - File shitFile = new File(getAssemblyName() + ".pdb") + File shitFile = new File(assemblyName.get() + ".pdb") if (shitFile.isFile()) { - FileUtils.moveFile(shitFile, debugFile) + Files.move(shitFile.toPath(), debugFile.toPath()) } } if (generateDoc && !project.gradle.taskGraph.hasTask(project.tasks.ikvmDoc)) { diff --git a/src/main/groovy/com/ullink/IkvmBasePlugin.groovy b/src/main/groovy/com/ullink/IkvmBasePlugin.groovy index 245449f..74db11b 100644 --- a/src/main/groovy/com/ullink/IkvmBasePlugin.groovy +++ b/src/main/groovy/com/ullink/IkvmBasePlugin.groovy @@ -1,18 +1,19 @@ package com.ullink + import org.gradle.api.Plugin import org.gradle.api.Project class IkvmBasePlugin implements Plugin { void apply(Project project) { project.tasks.withType(Ikvm).whenTaskAdded { Ikvm task -> - task.conventionMapping.map "ikvmVersion", { '7.2.4630.5' } - task.conventionMapping.map "ikvmHome", { + task.ikvmVersion.convention('7.2.4630.5') + task.ikvmHome.convention(project.provider { if (System.getenv()['IKVM_HOME']) { return System.getenv()['IKVM_HOME'] } - def version = task.getIkvmVersion() + def version = task.ikvmVersion.get() return "http://downloads.sourceforge.net/project/ikvm/ikvm/${version}/ikvmbin-${version}.zip" - } + }) } } } diff --git a/src/main/groovy/com/ullink/IkvmPlugin.groovy b/src/main/groovy/com/ullink/IkvmPlugin.groovy index 4691cbd..02c41a8 100644 --- a/src/main/groovy/com/ullink/IkvmPlugin.groovy +++ b/src/main/groovy/com/ullink/IkvmPlugin.groovy @@ -2,9 +2,9 @@ package com.ullink import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.Task; -import org.gradle.api.plugins.BasePlugin; -import org.gradle.api.plugins.JavaBasePlugin; +import org.gradle.api.Task +import org.gradle.api.plugins.BasePlugin +import org.gradle.api.plugins.JavaBasePlugin class IkvmPlugin implements Plugin { void apply(Project project) { diff --git a/src/test/groovy/com/ullink/IkvmPluginTest.groovy b/src/test/groovy/com/ullink/IkvmPluginTest.groovy index 96df51e..ad9cd69 100644 --- a/src/test/groovy/com/ullink/IkvmPluginTest.groovy +++ b/src/test/groovy/com/ullink/IkvmPluginTest.groovy @@ -1,7 +1,6 @@ package com.ullink import org.gradle.api.tasks.bundling.Jar -import org.junit.Before import static org.junit.Assert.* import org.gradle.api.Project @@ -10,7 +9,7 @@ import org.junit.Test class IkvmPluginTest { @Test - public void ikvmPluginAddsIkvmTasksToProject() { + void ikvmPluginAddsIkvmTasksToProject() { Project project = ProjectBuilder.builder().build() project.apply plugin: 'ikvm' assertTrue(project.tasks.ikvm instanceof Ikvm) @@ -22,7 +21,7 @@ class IkvmPluginTest { } @Test - public void ensureIkvmTaskdependsOnJarByDefault() { + void ensureIkvmTaskdependsOnJarByDefault() { Project project = ProjectBuilder.builder().build() project.apply plugin: 'ikvm' project.evaluate() @@ -30,7 +29,7 @@ class IkvmPluginTest { } @Test - public void shouldDependOnOtherTaskWhenTargetingAnotherJar() { + void shouldDependOnOtherTaskWhenTargetingAnotherJar() { Project project = ProjectBuilder.builder().build() project.apply plugin: 'ikvm' project.task('otherJar', type: Jar) { @@ -45,7 +44,7 @@ class IkvmPluginTest { } @Test - public void commandLineContainsJar() { + void commandLineContainsJar() { Project project = ProjectBuilder.builder().build() project.apply plugin: 'ikvm' def cmd = project.ikvm.commandLineArgs