KotlinScriptServiceRegistry.kt

Clone Tools
  • last updated a few seconds ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
Polish

- Normalise placement of `private`, `protected`, `internal` and

`inline` modifiers

  1. … 42 more files in changeset.
Move away from deprecated `ref.javaClass` to `ref::class.java`

See #264

  1. … 9 more files in changeset.
Polish top-level definitions, parameter lists and exceptions

* Separate top-level definitions by two lines

* Segregate visibility modifier of top-level definition to

its own line

* Prefer starting long parameter lists at the next line (more

sustainable in face of method renames)

* Remove unnecessary `Exception` suffix from class names

* Remove unnecessary prefixes from field names

* Use better name for exception variables

  1. … 38 more files in changeset.
Cache compiled scripts

- Introduce CachingKotlinCompiler

- Add compilation ClassPath (as ClassLoader) to cache key

- Add version number to script cache

- Honor `--recompile-scripts`

- Report compilation progress

Resolves #31

  1. … 5 more files in changeset.
Report API jar generation progress

Resolves #116

  1. … 10 more files in changeset.
Polish `KotlinScriptServiceRegistry`

    • -12
    • +12
    ./KotlinScriptServiceRegistry.kt
Include gsk version in the name of generated jars

So they are regenerated whenever a different gsk version is used.

  1. … 1 more file in changeset.
Polish whitespace

  1. … 2 more files in changeset.
Compile scripts against generated Kotlin API jar

We would like Kotlin build scripts to behave as if all the `Action<T>`

parameters in the Gradle API had been declared as `T.() -> Unit` to

avoid the need for explicitly qualifying the single argument to the

given lambda expressions with `it`.

In other words, we would like users to be writing code like:

copySpec {

from("src")

into("out")

}

Instead of:

copySpec {

it.from("src")

it.into("out")

}

Where `copySpec` is declared in the Gradle Java API as:

CopySpec copySpec(Action<? super CopySpec> configuration)

So far we have been able to avoid the qualifying `it` in some situations

via mindful use of inheritance and Kotlin extensions but a comprehensive

solution was still lacking. The underlying issue is that while Kotlin

does provide a type extension mechanism, type members still take

precedence over extensions and currently there's no mechanism to

instruct Kotlin otherwise.

In the future we might be able to implement a different solution to this

particular issue via a new Kotlin language feature still in discussion:

- https://youtrack.jetbrains.com/issue/KT-12848

In the meantime, by giving the Kotlin compiler a carefully crafted API

jar with all members that could potentially conflict with our provided

extensions removed we can work around the fact that interface members

take precedence over extension members and expose all the extensions we

want.

And that is the solution implemented in this commit:

- Remove all API methods that take a last `Action<T>` parameter

- Generate shim extensions that take a last `T.() -> Unit`

Proper treatment for generic types will be implemented in a future

commit.

Resolves: #52

See also: #54, #117

    • -0
    • +55
    ./KotlinScriptServiceRegistry.kt
  1. … 27 more files in changeset.