Skip to content

Commit

Permalink
(jruby-gradle#421) Add Kotlin plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ysb33r committed Sep 9, 2021
1 parent 06a1738 commit daf03ba
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 45 deletions.
39 changes: 26 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
plugins {
id 'com.gradle.build-scan' version '2.0.2'
id 'org.ysb33r.gradletest' version '2.0-rc.4' apply false
// id 'com.gradle.build-scan' version '3.6.3'
id 'org.ysb33r.gradletest' version '3.0.0-alpha.1' apply false
id 'org.ajoberstar.github-pages' version '1.2.0' apply false
id 'com.github.hierynomus.license' version '0.14.0' apply false
id 'io.ratpack.ratpack-java' version "1.6.1" apply false
id 'com.gradle.plugin-publish' version '0.14.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.5.10' apply false
}

buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
//buildScan {
// termsOfServiceUrl = 'https://gradle.com/terms-of-service'
// termsOfServiceAgree = 'yes'
//}

allprojects {
apply plugin: 'idea'
Expand All @@ -25,9 +26,9 @@ allprojects {

ext {
olderJRubyVersion = '9.2.1.0'
spockVersion = "org.spockframework:spock-core:1.2-groovy-2.4"
spockVersion = "org.spockframework:spock-core:2.0-groovy-2.5"
pluginExtraText = (version.contains('-alpha') || version.contains('-beta')) ?
'(If you need a production-ready version of the JRuby/Gradle plugin use a 1.7.x release instead)': ''
'(If you need a production-ready version of the JRuby/Gradle plugin use a 2.0.x release instead)': ''
}
}

Expand All @@ -48,10 +49,20 @@ subprojects {
apply from: "${rootProject.projectDir}/gradle/license.gradle"

dependencies {
compile localGroovy()
compile gradleApi()
compile "org.ysb33r.gradle:grolifant60:${grolifantVersion}"
gradleTestRuntime "org.ysb33r.gradle:grolifant60:${grolifantVersion}"
implementation localGroovy()
implementation gradleApi()
implementation "org.ysb33r.gradle:grolifant60:${grolifantVersion}"
testImplementation localGroovy()
testImplementation(spockVersion) {
exclude module: 'groovy-all'
exclude group: 'org.codehaus.groovy'
}

integrationTestImplementation(spockVersion) {
exclude module: 'groovy-all'
exclude group: 'org.codehaus.groovy'
}
gradleTestRuntimeOnly "org.ysb33r.gradle:grolifant60:${grolifantVersion}"
}

codenarc {
Expand All @@ -64,6 +75,7 @@ subprojects {
showStandardStreams = true
exceptionFormat "full"
}
useJUnitPlatform()
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand All @@ -72,6 +84,7 @@ subprojects {
}

gradleTest {

// https://github.com/jruby-gradle/jruby-gradle-plugin/issues/346
if (JavaVersion.current().java11) {
versions '5.0', '5.4.1', '6.0.1', '6.7'
Expand Down Expand Up @@ -126,6 +139,6 @@ subprojects {

task release(type: Exec) {
description 'Create and upload a release'
dependsOn subprojects.findAll { it.name != 'docs' }.collect { ":${it.name}:bintrayUpload" }
dependsOn subprojects.findAll { it.name != 'docs' }
commandLine 'git', 'tag', "v${project.version}"
}
11 changes: 0 additions & 11 deletions core-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
dependencies {
implementation "io.github.http-builder-ng:http-builder-ng-okhttp:${httpbuilderNgVersion}"
implementation "io.ratpack:ratpack-core:${ratpackVersion}"
integrationTestCompile gradleTestKit()

testCompile(spockVersion) {
exclude module: 'groovy-all'
exclude group: 'org.codehaus.groovy'
}

integrationTestCompile(spockVersion) {
exclude module: 'groovy-all'
exclude group: 'org.codehaus.groovy'
}
}

artifacts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,26 @@ package com.github.jrubygradle.api.core

import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.IgnoreIf
import spock.lang.Issue
import spock.lang.Specification
import spock.lang.TempDir

import java.util.regex.Pattern

@IgnoreIf({ System.getProperty('TESTS_ARE_OFFLINE') })
class IvyXmlProxyServerIntegrationSpec extends Specification {

@Rule
TemporaryFolder temporaryFolder
@TempDir File temporaryFolder

File projectDir
File buildFile
File testKitDir

void setup() {
projectDir = new File(temporaryFolder.root, 'test-project')
projectDir = new File(temporaryFolder, 'test-project')
buildFile = new File(projectDir, 'build.gradle')
testKitDir = new File(temporaryFolder.root, '.gradle')
testKitDir = new File(temporaryFolder, '.gradle')
testKitDir.deleteDir()
projectDir.deleteDir()
testKitDir.mkdirs()
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=2.1.0-alpha.3
version=2.1.0-beta.1
group=com.github.jruby-gradle
copyrightYear=2014-2021

Expand All @@ -14,7 +14,7 @@ releaseBuild=false
targetCompatibility=1.8
sourceCompatibility=1.8

grolifantVersion=1.0.0-alpha.6
grolifantVersion=1.2.1
jrubyVersion=9.2.9.0
jettyVersion=9.2.12.v20150709
bcprovVersion=1.46
Expand Down
16 changes: 9 additions & 7 deletions gradle/integration-tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
// https://raw.githubusercontent.com/robfletcher/gradle-compass/master/gradle/integration-tests.gradle

configurations {
integrationTestCompile {
extendsFrom testCompile
integrationTestImplementation {
extendsFrom testImplementation
}
integrationTestRuntime {
extendsFrom integrationTestCompile, testRuntime
integrationTestRuntimeClasspath {
extendsFrom integrationTestImplementation, testRuntimeClasspath
}
integrationTestGems
}

dependencies {
integrationTestCompile gradleTestKit()
// integrationTestImplementation localGroovy()
integrationTestImplementation gradleTestKit()

/* We want to cache jruby-complete at this alternative version which we use
* in many places
Expand All @@ -25,8 +26,8 @@ sourceSets {
java.srcDir file("src/integTest/java")
groovy.srcDir file("src/integTest/groovy")
resources.srcDir file("src/integTest/resources")
compileClasspath = sourceSets.main.output + configurations.integrationTestCompile
runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
compileClasspath = sourceSets.main.output + configurations.integrationTestCompileClasspath
runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntimeClasspath
}
}

Expand All @@ -41,5 +42,6 @@ task integrationTest(type: Test, dependsOn: jar) {
dependsOn copyIntegrationTestGems
mustRunAfter test
systemProperties TMP_FOLDER : file('build/tmp/integrationTestTempFolder').absolutePath
useJUnitPlatform()
}
check.dependsOn integrationTest
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 17 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/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.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ 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"
Expand Down
18 changes: 17 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
20 changes: 20 additions & 0 deletions kotlindsl-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
}

dependencies {
api project(':jruby-gradle-core-plugin')
implementation platform('org.jetbrains.kotlin:kotlin-bom')
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
}

pluginBundle {
plugins {
gradlePlugin {
id = 'com.github.jruby-gradle.kotlindsl'
displayName = 'JRuby/Gradle Kotlin-DSL extensions plugin'
description = 'This plugin provides some extensions for JRuby/Gradle to simplify usage for Kotlin DSL users'
tags = (['jruby','kotlin'])
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2014-2021, R. Tyler Croy <[email protected]>,
* Schalk Cronje <[email protected]>, Christian Meier, Lookout, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.jrubygradle.kdsl

import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import spock.lang.IgnoreIf
import spock.lang.Specification
import spock.lang.TempDir

import java.util.regex.Pattern

@IgnoreIf({ System.getProperty('TESTS_ARE_OFFLINE') })
class KotlinDslExtensionsSpec extends Specification {

@TempDir File temporaryFolder

File projectDir
File buildFile
File testKitDir

void setup() {
projectDir = new File(temporaryFolder, 'test-project')
buildFile = new File(projectDir, 'build.gradle.kts')
testKitDir = new File(temporaryFolder, '.gradle')
testKitDir.deleteDir()
projectDir.deleteDir()
testKitDir.mkdirs()
projectDir.mkdirs()
}

void 'Apply ruby.gems from core-plugin'() {
setup:
withBuildFile('')

when:
def result = build()

then:
noExceptionThrown()
}

private BuildResult build() {
GradleRunner.create()
.withProjectDir(projectDir)
.withPluginClasspath()
.withTestKitDir(testKitDir)
.withArguments(['dependencies', '-s'])
.forwardOutput()
.build()
}

private void withBuildFile(String content, boolean prerelease = false) {
buildFile.text = """
plugins {
id("com.github.jruby-gradle.core")
id("com.github.jruby-gradle.kotlindsl")
}
repositories {
ruby{
gems {
prerelease = ${prerelease}
}
}
}
configurations {
create("something")
}
dependencies {
something("rubygems:asciidoctor-revealjs:2.0.0")
}
"""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.github.jrubygradle.kdsl

import com.github.jrubygradle.api.core.RepositoryHandlerExtension
import org.gradle.api.Action
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.plugins.ExtensionAware

val RepositoryHandler.ruby: RepositoryHandlerExtension
get() =
(this as ExtensionAware).extensions.getByName("ruby") as RepositoryHandlerExtension

fun RepositoryHandler.ruby(configure: Action<RepositoryHandler>): Unit =
(this as ExtensionAware).extensions.configure("ruby", configure)
Loading

0 comments on commit daf03ba

Please sign in to comment.