Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Virtlink committed Jul 19, 2024
1 parent 7367e43 commit 618228e
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 89 deletions.
11 changes: 11 additions & 0 deletions docs/content/conventions/index.md
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)
32 changes: 32 additions & 0 deletions docs/content/conventions/java.md
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))
}
```



48 changes: 48 additions & 0 deletions docs/content/conventions/junit.md
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>")
}
```



81 changes: 81 additions & 0 deletions docs/content/conventions/mavenpublish.md
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")
}
}
```



29 changes: 29 additions & 0 deletions docs/content/conventions/rootproject.md
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")
}
```
37 changes: 37 additions & 0 deletions docs/content/conventions/settings.md
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.
}
```
86 changes: 2 additions & 84 deletions docs/content/index.md
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"
}
```
17 changes: 12 additions & 5 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# yaml-language-server: $schema=https://squidfunk.github.io/mkdocs-material/schema.json
site_name: Metaborg Gradle Convention
site_description: Metaborg Gradle Convention
site_name: Metaborg Gradle
site_description: Metaborg Gradle
site_author: Daniel A. A. Pelsmaeker

docs_dir: content/
Expand All @@ -11,26 +11,33 @@ edit_uri: https://github.com/metaborg/metaborg-gradle/edit/main/docs
nav:
- Home:
- index.md
- Conventions:
- conventions/index.md
- conventions/java.md
- conventions/junit.md
- conventions/mavenpublish.md
- conventions/rootproject.md
- conventions/settings.md

theme:
name: material
language: en
icon:
logo: fontawesome/solid/book
logo: fontawesome/solid/diagram-project
repo: fontawesome/brands/github
palette:
# Light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: blue grey
primary: indigo
accent: orange
toggle:
icon: material/weather-night
name: Switch to dark mode
# Dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: blue grey
primary: indigo
accent: orange
toggle:
icon: material/weather-sunny
Expand Down

0 comments on commit 618228e

Please sign in to comment.