forked from jruby-gradle/jruby-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(jruby-gradle#421) Add Kotlin plugin
- Loading branch information
Showing
15 changed files
with
220 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']) | ||
} | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
...sl-plugin/src/integTest/groovy/com/github/jrubygradle/kdsl/KotlinDslExtensionsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
""" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
kotlindsl-plugin/src/main/kotlin/com/github/jrubygradle/kdsl/Extensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.