-
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
8 changed files
with
252 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: "Convention Plugins" | ||
--- | ||
# Convention Plugins | ||
This repository publishes a number of Gradle convention plugins for Spoofax/Metaborg projects. | ||
|
||
- [Java Convention](./java-convention.md) | ||
- [JUnit Convention](./junit-convention.md) | ||
- [Maven Publish Convention](./mavenpublish-convention.md) | ||
- [Root Project Convention](./rootproject-convention.md) | ||
- [Settings Convention](./settings-convention.md) |
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,32 @@ | ||
--- | ||
title: "Java Convention" | ||
--- | ||
# Java Convention Plugin | ||
The Java convention plugin configures a project to be built using Java 11 by default, but this can be overridden. | ||
|
||
To use the plugin, you need to apply both the Java convention plugin and one of the Java plugins (`java-library`, `java`): | ||
|
||
```kotlin title="build.gradle.kts" | ||
plugins { | ||
id("org.metaborg.convention.java") version "<version>" | ||
`java-library` | ||
} | ||
``` | ||
|
||
!!! note "Kotlin" | ||
When using Kotlin, it will automatically use the configured JVM toolchain. | ||
|
||
|
||
|
||
## Configuration | ||
The plugin can be configured using the `javaConvention` extension: | ||
|
||
```kotlin title="build.gradle.kts" | ||
javaConvention { | ||
// The Java version to use | ||
javaVersion.set(JavaLanguageVersion.of(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,48 @@ | ||
--- | ||
title: "JUnit Convention" | ||
--- | ||
# JUnit Convention Plugin | ||
The JUnit convention plugin configures a Java project to use JUnit 5 for testing, and also adds a JUnit dependency. | ||
|
||
To use the plugin, you need to apply it to the project: | ||
|
||
```kotlin title="build.gradle.kts" | ||
plugins { | ||
id("org.metaborg.convention.junit") version "<version>" | ||
} | ||
``` | ||
|
||
!!! note "JUnit Dependency" | ||
If a version catalog is configured, this plugin automatically adds the following dependency: | ||
|
||
```kotlin | ||
dependencies { | ||
testImplementation(libs.junit) | ||
} | ||
``` | ||
|
||
If the project has no version catalog, it adds the following dependency: | ||
|
||
```kotlin | ||
dependencies { | ||
testImplementation("org.junit.jupiter:junit-jupiter:<version>") | ||
} | ||
``` | ||
|
||
|
||
## Configuration | ||
The plugin can be configured using the `junitConvention` extension: | ||
|
||
```kotlin title="build.gradle.kts" | ||
junitConvention { | ||
// The name of the version catalog to use | ||
versionCatalogName.set("libs") | ||
// The alias of the JUnit library in the version catalog | ||
jUnitAlias.set("junit") | ||
// The dependency of JUnit to use if it is not found in the version catalog | ||
jUnitDependency.set("org.junit.jupiter:junit-jupiter:<version>") | ||
} | ||
``` | ||
|
||
|
||
|
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,81 @@ | ||
--- | ||
title: "Maven Publish Convention" | ||
--- | ||
# Maven Publish Convention Plugin | ||
The Maven Publish convention plugin adds metadata to existing publications, and sets up GitHub Packages and Metaborg Artifacts as target publication repositories. A minimal configuration looks like this: | ||
|
||
```kotlin title="build.gradle.kts" | ||
plugins { | ||
id("org.metaborg.convention.maven-publish") version "<version>" | ||
} | ||
|
||
// Group must be set | ||
group = "org.metaborg" | ||
|
||
// The repository owner and name must be set | ||
mavenPublishConvention { | ||
repoOwner.set("metaborg") | ||
repoName.set("convention-plugin-example") | ||
} | ||
|
||
// A publication must have been created | ||
publishing { | ||
publications { | ||
create<MavenPublication>("mavenJava") { | ||
from(components["java"]) | ||
} | ||
} | ||
} | ||
``` | ||
|
||
The `repoOwner` and `repoName` fields must be set, but usually it is easier to set it once on the root project's `build.gradle.kts` for all projects that apply the Maven Publish convention plugin, like this: | ||
|
||
```kotlin title="build.gradle.kts" | ||
allprojects { | ||
pluginManager.withPlugin("org.metaborg.convention.maven-publish") { | ||
extensions.configure(org.metaborg.convention.MavenPublishConventionExtension::class.java) { | ||
repoOwner.set("metaborg") | ||
repoName.set("convention-plugin-example") | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
## Configuration | ||
The plugin can be configured using the `mavenPublishConvention` extension: | ||
|
||
```kotlin title="build.gradle.kts" | ||
mavenPublishConvention { | ||
// The owner of the GitHub repository | ||
repoOwner.set("<owner>") | ||
// The name of the GitHub repository | ||
repoName.set("<name>") | ||
// Whether to publish to GitHub packages. | ||
publishToGitHubPackages.set(true) | ||
// Whether to publish to Metaborg Artifacts. | ||
publishToMetaborgArtifacts.set(true) | ||
|
||
metadata { | ||
// The year the project was started | ||
inceptionYear.set("2021") | ||
// The developers of the project | ||
developers.set( | ||
listOf( | ||
Developer("<username>", "<full name>", "<email>"), | ||
) | ||
) | ||
// The source control management system | ||
scm.set(SCM.GitHub) | ||
// The license of the project | ||
license.set(OpenSourceLicense.Apache2) | ||
// The HTTP SCM URL format | ||
httpUrlFormat.set("https://github.com/%s/%s") | ||
// The SCM URL format | ||
scmUrlFormat.set("scm:[email protected]:%s/%s.git") | ||
} | ||
} | ||
``` | ||
|
||
|
||
|
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,29 @@ | ||
--- | ||
title: "Root Project Convention" | ||
--- | ||
# Root Project Convention Plugin | ||
The Root Project convention plugin adds tasks that invoke the corresponding tasks on the sub-builds and subprojects. | ||
|
||
```kotlin title="build.gradle.kts" | ||
plugins { | ||
id("org.metaborg.convention.root-project") version "<version>" | ||
} | ||
``` | ||
|
||
## Configuration | ||
The plugin can be configured using the `rootProjectConvention` extension: | ||
|
||
```kotlin title="build.gradle.kts" | ||
rootProjectConvention { | ||
// The suffix for tasks that invoke tasks in subprojects and included builds | ||
taskNameSuffix.set("All") | ||
assembleTaskName.set("assembleAll") | ||
buildTaskName.set("buildAll") | ||
cleanTaskName.set("cleanAll") | ||
publishTaskName.set("publishAll") | ||
publishToMavenLocalTaskName.set("publishAllToMavenLocal") | ||
checkTaskName.set("checkAll") | ||
testTaskName.set("testAll") | ||
tasksTaskName.set("allTasks") | ||
} | ||
``` |
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,37 @@ | ||
--- | ||
title: "Root Project Convention" | ||
--- | ||
# Settings Convention Plugin | ||
The Settings convention applies the Gradle Develocity and Foojay plugins, and installs the Metaborg version catalog. | ||
|
||
```kotlin title="settings.gradle.kts" | ||
pluginManagement { | ||
repositories { | ||
maven("https://artifacts.metaborg.org/content/groups/public/") | ||
} | ||
} | ||
|
||
plugins { | ||
id("org.metaborg.convention.settings") version "0.0.11" | ||
} | ||
``` | ||
|
||
!!! warning "" | ||
In contrast to the other plugin, the Settings convention plugin must be applied in the project's `settings.gradle.kts`. | ||
|
||
!!! note "" | ||
After applying the Settings convention plugin, other plugins applied in projects' `build.gradle.kts` files no longer need a version number. | ||
|
||
!!! tip "" | ||
After configuring the plugin, you can use the `libs` version catalog to add dependencies to your project. | ||
See the [Version Catalog](https://github.com/metaborg/metaborg-gradle/blob/main/depman/gradle/libs.versions.toml) to see the defined libraries. | ||
|
||
|
||
## Configuration | ||
The plugin can be configured using the `settingsConvention` extension: | ||
|
||
```kotlin title="settings.gradle.kts" | ||
settingsConvention { | ||
// No options. | ||
} | ||
``` |
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,88 +1,6 @@ | ||
--- | ||
title: "Gradle Convention" | ||
title: "Home" | ||
--- | ||
# Gradle Convention | ||
|
||
# Metaborg Gradle | ||
The Metaborg Gradle convention and development plugins. | ||
|
||
## Java Convention | ||
The Java convention plugin configures a project to be built using Java 11 by default, but this can be overridden. | ||
|
||
To apply the plugin: | ||
|
||
```kotlin title="build.gradle.kts" | ||
plugins { | ||
id("org.metaborg.convention.java") version "<version>" | ||
`java-library` | ||
} | ||
``` | ||
|
||
!!! note "Kotlin" | ||
When using Kotlin, it will automatically use the configured JVM toolchain. | ||
|
||
|
||
## Maven Publish Convention | ||
The Maven Publish convention plugin adds metadata to existing publications, and sets up GitHub Packages and Metaborg Artifacts as target publication repositories. A minimal configuration looks like this: | ||
|
||
```kotlin title="build.gradle.kts" | ||
plugins { | ||
id("org.metaborg.convention.maven-publish") version "<version>" | ||
} | ||
|
||
// Group must be set | ||
group = "org.metaborg" | ||
|
||
// The repository owner and name must be set | ||
mavenPublishConvention { | ||
repoOwner.set("metaborg") | ||
repoName.set("convention-plugin-example") | ||
} | ||
|
||
// A publication must have been created | ||
publishing { | ||
publications { | ||
create<MavenPublication>("mavenJava") { | ||
from(components["java"]) | ||
} | ||
} | ||
} | ||
``` | ||
|
||
The `repoOwner` and `repoName` fields must be set, but usually it is easier to set it once on the root project's `build.gradle.kts` for all projects that apply the Maven Publish convention plugin, like this: | ||
|
||
```kotlin title="build.gradle.kts" | ||
allprojects { | ||
pluginManager.withPlugin("org.metaborg.convention.maven-publish") { | ||
extensions.configure(MavenPublishConventionExtension::class.java) { | ||
repoOwner.set("metaborg") | ||
repoName.set("convention-plugin-example") | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
## Root Project Convention | ||
The Root Project convention plugin adds tasks that invoke the corresponding tasks on the sub-builds and subprojects. | ||
|
||
```kotlin title="build.gradle.kts" | ||
plugins { | ||
id("org.metaborg.convention.root-project") version "<version>" | ||
} | ||
``` | ||
|
||
|
||
## Settings Convention | ||
The Settings convention applies the Gradle Develocity and Foojay plugins, and installs the Metaborg version catalog. | ||
|
||
```kotlin title="settings.gradle.kts" | ||
pluginManagement { | ||
repositories { | ||
maven("https://artifacts.metaborg.org/content/groups/public/") | ||
} | ||
} | ||
|
||
plugins { | ||
id("org.metaborg.convention.settings") version "0.0.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