-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
playing around with re-adapted early-prototype declarative Gradle
- Loading branch information
Showing
33 changed files
with
686 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
.idea/modules/declarative/buildSrc/declarative.buildSrc.main.iml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 @@ | ||
//import org.gradle.api.experimental.java.javaLibrary | ||
|
||
plugins { | ||
|
||
} | ||
|
||
//javaLibrary { | ||
// javaVersion = 11 | ||
//} |
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,7 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} |
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 @@ | ||
rootProject.name = "buildSrc" |
15 changes: 15 additions & 0 deletions
15
...ve/buildSrc/src/main/kotlin/org/gradle/api/experimental/common/ApplicationDependencies.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,15 @@ | ||
package org.gradle.api.experimental.common | ||
|
||
import org.gradle.api.artifacts.dsl.Dependencies | ||
import org.gradle.api.artifacts.dsl.DependencyCollector | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* The declarative dependencies DSL block for an application. | ||
*/ | ||
@Restricted | ||
interface ApplicationDependencies : Dependencies { | ||
val implementation: DependencyCollector | ||
val runtimeOnly: DependencyCollector | ||
val compileOnly: DependencyCollector | ||
} |
19 changes: 19 additions & 0 deletions
19
...rative/buildSrc/src/main/kotlin/org/gradle/api/experimental/common/LibraryDependencies.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,19 @@ | ||
package org.gradle.api.experimental.common | ||
|
||
import org.gradle.api.artifacts.dsl.Dependencies | ||
import org.gradle.api.artifacts.dsl.DependencyCollector | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* The declarative dependencies DSL block for a library. | ||
*/ | ||
@Restricted | ||
interface LibraryDependencies : Dependencies { | ||
val api: DependencyCollector | ||
val implementation: DependencyCollector | ||
val runtimeOnly: DependencyCollector | ||
val compileOnly: DependencyCollector | ||
// CompileOnlyApi is not included here, since both Android and KMP do not support it. | ||
// Does that mean we should also reconsider if we should support it? Or, should we | ||
// talk to Android and KMP about adding support | ||
} |
11 changes: 11 additions & 0 deletions
11
.../declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/java/JavaApplication.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,11 @@ | ||
package org.gradle.api.experimental.java | ||
|
||
import org.gradle.api.experimental.jvm.HasJavaTarget | ||
import org.gradle.api.experimental.jvm.HasJvmApplication | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* An application implemented using a single version of Java. | ||
*/ | ||
@Restricted | ||
interface JavaApplication : HasJavaTarget, HasJvmApplication |
22 changes: 22 additions & 0 deletions
22
gradle/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/java/JavaLibrary.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,22 @@ | ||
package org.gradle.api.experimental.java | ||
|
||
import org.gradle.api.experimental.common.LibraryDependencies | ||
import org.gradle.api.experimental.jvm.HasJavaTarget | ||
import org.gradle.api.experimental.jvm.HasJvmLibrary | ||
import org.gradle.api.provider.Property | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* A library implemented using a single version of Java. | ||
*/ | ||
@Restricted | ||
interface JavaLibrary : HasJavaTarget, HasJvmLibrary | ||
|
||
//inline fun javaLibrary(block: JavaLibrary.() -> Unit): JavaLibrary { | ||
// return object : JavaLibrary{ | ||
// override val javaVersion: Property<Int> = Property | ||
// override val dependencies: LibraryDependencies | ||
// get() = TODO("Not yet implemented") | ||
// | ||
// }.also(block) | ||
//} |
30 changes: 30 additions & 0 deletions
30
...ldSrc/src/main/kotlin/org/gradle/api/experimental/java/StandaloneJavaApplicationPlugin.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,30 @@ | ||
package org.gradle.api.experimental.java | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.experimental.jvm.internal.JvmPluginSupport | ||
import org.gradle.api.internal.plugins.software.SoftwareType | ||
import org.gradle.api.plugins.ApplicationPlugin | ||
|
||
/** | ||
* Creates a declarative [JavaApplication] DSL model, applies the official Java application plugin, | ||
* and links the declarative model to the official plugin. | ||
*/ | ||
abstract class StandaloneJavaApplicationPlugin : Plugin<Project> { | ||
@get:SoftwareType(name = "javaApplication", modelPublicType = JavaApplication::class) | ||
abstract val application: JavaApplication | ||
|
||
override fun apply(project: Project) { | ||
val dslModel = application | ||
|
||
project.plugins.apply(ApplicationPlugin::class.java) | ||
|
||
linkDslModelToPlugin(project, dslModel) | ||
} | ||
|
||
private fun linkDslModelToPlugin(project: Project, dslModel: JavaApplication) { | ||
JvmPluginSupport.linkJavaVersion(project, dslModel) | ||
JvmPluginSupport.linkApplicationMainClass(project, dslModel) | ||
JvmPluginSupport.linkMainSourceSourceSetDependencies(project, dslModel.dependencies) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
.../buildSrc/src/main/kotlin/org/gradle/api/experimental/java/StandaloneJavaLibraryPlugin.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,28 @@ | ||
package org.gradle.api.experimental.java | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.experimental.jvm.internal.JvmPluginSupport | ||
import org.gradle.api.internal.plugins.software.SoftwareType | ||
import org.gradle.api.plugins.JavaLibraryPlugin | ||
|
||
/** | ||
* Creates a declarative [JavaLibrary] DSL model, applies the official Java library plugin, | ||
* and links the declarative model to the official plugin. | ||
*/ | ||
abstract class StandaloneJavaLibraryPlugin : Plugin<Project> { | ||
@get:SoftwareType(name = "javaLibrary", modelPublicType = JavaLibrary::class) abstract val library: JavaLibrary | ||
|
||
override fun apply(project: Project) { | ||
val dslModel = library | ||
|
||
project.plugins.apply(JavaLibraryPlugin::class.java) | ||
|
||
linkDslModelToPlugin(project, dslModel) | ||
} | ||
|
||
private fun linkDslModelToPlugin(project: Project, dslModel: JavaLibrary) { | ||
JvmPluginSupport.linkJavaVersion(project, dslModel) | ||
JvmPluginSupport.linkMainSourceSourceSetDependencies(project, dslModel.dependencies) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
gradle/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/HasJavaTarget.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 org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.api.provider.Property | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* A component that is built for a single Java version. | ||
*/ | ||
@Restricted | ||
interface HasJavaTarget { | ||
@get:Restricted | ||
val javaVersion: Property<Int> | ||
} |
18 changes: 18 additions & 0 deletions
18
...le/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/HasJavaTargets.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,18 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.api.tasks.Nested | ||
import org.gradle.declarative.dsl.model.annotations.Configuring | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* A component that is built for multiple Java versions. | ||
*/ | ||
@Restricted | ||
interface HasJavaTargets { | ||
@get:Nested | ||
val targets: JvmTargetContainer | ||
|
||
@Configuring | ||
fun targets(action: Action<in JvmTargetContainer>) = action.execute(targets) | ||
} |
23 changes: 23 additions & 0 deletions
23
...declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/HasJvmApplication.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,23 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.api.experimental.common.ApplicationDependencies | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Nested | ||
import org.gradle.declarative.dsl.model.annotations.Configuring | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* Represents an application that runs on the JVM. | ||
*/ | ||
@Restricted | ||
interface HasJvmApplication { | ||
@get:Restricted | ||
val mainClass: Property<String> | ||
|
||
@get:Nested | ||
val dependencies: ApplicationDependencies | ||
|
||
@Configuring | ||
fun dependencies(action: Action<in ApplicationDependencies>) = action.execute(dependencies) | ||
} |
19 changes: 19 additions & 0 deletions
19
gradle/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/HasJvmLibrary.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,19 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.api.experimental.common.LibraryDependencies | ||
import org.gradle.api.tasks.Nested | ||
import org.gradle.declarative.dsl.model.annotations.Configuring | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* Represents a library that runs on the JVM. | ||
*/ | ||
@Restricted | ||
interface HasJvmLibrary { | ||
@get:Nested | ||
val dependencies: LibraryDependencies | ||
|
||
@Configuring | ||
fun dependencies(action: Action<in LibraryDependencies>) = action.execute(dependencies) | ||
} |
7 changes: 7 additions & 0 deletions
7
gradle/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/JavaTarget.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,7 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.api.Named | ||
|
||
abstract class JavaTarget(val javaVersion: Int) : JvmTarget, Named { | ||
override fun getName(): String = "java$javaVersion" | ||
} |
6 changes: 6 additions & 0 deletions
6
...le/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/JvmApplication.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,6 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
/** | ||
* An application that runs on the JVM and that is implemented using one or more versions of Java. | ||
*/ | ||
interface JvmApplication : HasJavaTargets, HasJvmApplication |
15 changes: 15 additions & 0 deletions
15
...eclarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/JvmEcosystemPlugin.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,15 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.experimental.java.StandaloneJavaApplicationPlugin | ||
import org.gradle.api.experimental.java.StandaloneJavaLibraryPlugin | ||
import org.gradle.api.initialization.Settings | ||
import org.gradle.api.internal.plugins.software.RegistersSoftwareTypes | ||
|
||
@RegistersSoftwareTypes(StandaloneJavaApplicationPlugin::class, | ||
StandaloneJavaLibraryPlugin::class, | ||
StandaloneJvmLibraryPlugin::class, | ||
StandaloneJvmApplicationPlugin::class) | ||
class JvmEcosystemPlugin : Plugin<Settings> { | ||
override fun apply(target: Settings) {} | ||
} |
9 changes: 9 additions & 0 deletions
9
gradle/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/JvmLibrary.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,9 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
/** | ||
* A library that runs on the JVM and that is implemented using one or more versions of Java. | ||
*/ | ||
@Restricted | ||
interface JvmLibrary : HasJavaTargets, HasJvmLibrary |
17 changes: 17 additions & 0 deletions
17
gradle/declarative/buildSrc/src/main/kotlin/org/gradle/api/experimental/jvm/JvmTarget.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,17 @@ | ||
package org.gradle.api.experimental.jvm | ||
|
||
import org.gradle.api.Action | ||
import org.gradle.api.Named | ||
import org.gradle.api.experimental.common.LibraryDependencies | ||
import org.gradle.api.tasks.Nested | ||
import org.gradle.declarative.dsl.model.annotations.Configuring | ||
import org.gradle.declarative.dsl.model.annotations.Restricted | ||
|
||
@Restricted | ||
interface JvmTarget : Named { | ||
@get:Nested | ||
val dependencies: LibraryDependencies | ||
|
||
@Configuring | ||
fun dependencies(action: Action<in LibraryDependencies>) = action.execute(dependencies) | ||
} |
Oops, something went wrong.