-
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.
- Loading branch information
Showing
7 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
convention-plugin/src/main/kotlin/org/metaborg/gradle/Developer.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.metaborg.gradle | ||
|
||
/** Specifies a developer. */ | ||
data class Developer( | ||
/** The developer's ID or username. */ | ||
val id: String, | ||
/** The developer's full name. */ | ||
val name: String, | ||
/** The developer's email address. */ | ||
val email: String, | ||
) |
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
45 changes: 45 additions & 0 deletions
45
convention-plugin/src/main/kotlin/org/metaborg/gradle/MavenPublishConventionExtension.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,45 @@ | ||
package org.metaborg.gradle | ||
|
||
import org.gradle.api.provider.ListProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
|
||
/** Configuration for the Maven Publish convention. */ | ||
interface MavenPublishConventionExtension { | ||
/** The owner of the repository. */ | ||
val repoOwner: Property<String> | ||
/** The name of the repository. */ | ||
val repoName: Property<String> | ||
/** The year the project was started. */ | ||
val inceptionYear: Property<String> | ||
/** The developers of the project. */ | ||
val developers: ListProperty<Developer> | ||
/** The source control management system. */ | ||
val scm: Property<SCM> | ||
/** The open source license that the project is published under. */ | ||
val license: Property<OpenSourceLicense> | ||
/** Whether to publish to GitHub packages. */ | ||
val publishToGitHubPackages: Property<Boolean> | ||
/** Whether to publish to Metaborg Artifacts. */ | ||
val publishToMetaborgArtifacts: Property<Boolean> | ||
/** Whether to sign the artifacts. */ | ||
val sign: Property<Boolean> | ||
/** The HTTP SCM URL format. */ | ||
val httpUrlFormat: Property<String> | ||
/** The SCM URL format. */ | ||
val scmUrlFormat: Property<String> | ||
|
||
|
||
/** | ||
* Sets the convention (default values) for the configuration extension. | ||
*/ | ||
fun setConvention() { | ||
scm.convention(SCM.GitHub) | ||
license.convention(OpenSourceLicense.Apache2) | ||
publishToGitHubPackages.convention(scm.map { it == SCM.GitHub }) | ||
publishToMetaborgArtifacts.convention(true) | ||
sign.convention(false) // Not yet supported | ||
httpUrlFormat.convention(scm.map { it.httpUrlFormat }) | ||
scmUrlFormat.convention(scm.map { it.scmUrlFormat }) | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
convention-plugin/src/main/kotlin/org/metaborg/gradle/OpenSourceLicense.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,14 @@ | ||
package org.metaborg.gradle | ||
|
||
/** Specifies the open source license. */ | ||
enum class OpenSourceLicense( | ||
/** The unique identifier of the license. */ | ||
val id: String, | ||
/** The license URL. */ | ||
val url: String, | ||
) { | ||
// From: https://spdx.org/licenses/ | ||
|
||
/** Apache 2 */ | ||
Apache2("Apache-2.0", "https://www.apache.org/licenses/LICENSE-2.0.txt"), | ||
} |
12 changes: 12 additions & 0 deletions
12
convention-plugin/src/main/kotlin/org/metaborg/gradle/SCM.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,12 @@ | ||
package org.metaborg.gradle | ||
|
||
/** Specifies a source control management system. */ | ||
enum class SCM( | ||
/** The HTTP URL for the SCM. */ | ||
val httpUrlFormat: String, | ||
/** The SCM URL for the SCM. */ | ||
val scmUrlFormat: String, | ||
) { | ||
/** GitHub */ | ||
GitHub("https://github.com/%s/%s", "scm:[email protected]:%s/%s.git"), | ||
} |
15 changes: 15 additions & 0 deletions
15
convention-plugin/src/main/kotlin/org/metaborg/gradle/Utils.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.metaborg.gradle | ||
|
||
import org.gradle.api.provider.Provider | ||
|
||
private fun <A0, A1> zipId(p0: Provider<A0>, p1: Provider<A1>): Provider<Pair<A0, A1>> = | ||
p0.zip(p1) { a0, a1 -> Pair(a0, a1) } | ||
|
||
fun <A0, A1, R> Provider<A0>.with(p1: Provider<A1>, transformer: (A0, A1) -> R): Provider<R> = | ||
this.zip(p1) { a0, a1 -> transformer(a0, a1) } | ||
|
||
fun <A0, A1, A2, R> Provider<A0>.with(p1: Provider<A1>, p2: Provider<A2>, transformer: (A0, A1, A2) -> R): Provider<R> = | ||
this.zip(zipId(p1, p2)) { a0, (a1, a2) -> transformer(a0, a1, a2) } | ||
|
||
fun <A0, A1, A2, A3, R> Provider<A0>.with(p1: Provider<A1>, p2: Provider<A2>, p3: Provider<A3>, transformer: (A0, A1, A2, A3) -> R): Provider<R> = | ||
this.zip(zipId(p1, zipId(p2, p3))) { a0, (a1, a23) -> val (a2, a3) = a23; transformer(a0, a1, a2, a3) } |