Skip to content

Commit

Permalink
Add shadowJar plugin to produce artifacts with dependencies included
Browse files Browse the repository at this point in the history
  • Loading branch information
pemistahl committed Jan 9, 2024
1 parent 1801a9e commit 6d5958d
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Create release and upload artifacts
uses: softprops/action-gh-release@v1
with:
name: Version Catalog Linter Gradle Plugin ${{ steps.version.outputs.version-without-v }}
name: Version Catalog Linter ${{ steps.version.outputs.version-without-v }}
files: build/libs/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Version Catalog Linter Gradle Plugin

[![build status](https://github.com/pemistahl/version-catalog-linter-gradle-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/pemistahl/version-catalog-linter-gradle-plugin/actions/workflows/build.yml)
[![Gradle Plugin Portal](https://img.shields.io/gradle-plugin-portal/v/io.github.pemistahl.version-catalog-linter)](https://plugins.gradle.org/plugin/io.github.pemistahl.version-catalog-linter)
[![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

## What does this plugin do?
Expand All @@ -18,7 +19,7 @@ Add the plugin to your Gradle build file.

```kotlin
plugins {
id("io.github.pemistahl.version-catalog-linter") version "1.0.0"
id("io.github.pemistahl.version-catalog-linter") version "1.0.1"
}
```

Expand Down
9 changes: 8 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Version Catalog Linter Gradle Plugin 1.0.0 (released on Jan 07 2024)
## Version Catalog Linter 1.0.1 (released on Jan 09 2024)

### Improvements

- The shadowJar plugin has been applied to produce
artifacts with all dependencies included for convenience.

## Version Catalog Linter 1.0.0 (released on Jan 07 2024)

This is the very first release. Enjoy!
9 changes: 8 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
kotlin("jvm") version "1.9.22"
id("org.jlleitschuh.gradle.ktlint") version "12.0.3"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.gradle.plugin-publish") version "1.2.1"
}

group = "io.github.pemistahl"
version = "1.0.0"
version = "1.0.1"

kotlin {
compilerOptions {
Expand All @@ -42,6 +43,7 @@ testing {
if (this is JvmTestSuite) {
useJUnitJupiter()
dependencies {
implementation(gradleApi())
implementation("org.jetbrains.kotlin:kotlin-test")
implementation("org.jetbrains.kotlin:kotlin-test-junit5")
}
Expand Down Expand Up @@ -71,6 +73,11 @@ tasks.check {
dependsOn(testing.suites.named("functionalTest"))
}

tasks.shadowJar {
archiveClassifier = ""
isEnableRelocation = true
}

gradlePlugin {
plugins {
create("versionCatalogLinter") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.gradle.testkit.runner.TaskOutcome
import java.io.File
import kotlin.io.path.createDirectories
import kotlin.io.path.createFile
import kotlin.io.path.deleteExisting
import kotlin.io.path.deleteIfExists
import kotlin.io.path.readText
import kotlin.io.path.writeText
import kotlin.test.AfterTest
Expand Down Expand Up @@ -144,10 +144,10 @@ class VersionCatalogLinterPluginFunctionalTest {

@AfterTest
fun afterTest() {
buildFilePath.deleteExisting()
settingsFilePath.deleteExisting()
versionCatalogFilePath.deleteExisting()
customVersionCatalogFilePath.deleteExisting()
buildFilePath.deleteIfExists()
settingsFilePath.deleteIfExists()
versionCatalogFilePath.deleteIfExists()
customVersionCatalogFilePath.deleteIfExists()
}

@Test
Expand Down Expand Up @@ -286,6 +286,37 @@ class VersionCatalogLinterPluginFunctionalTest {
assertEquals(unformattedVersionCatalogContent, defaultVersionCatalogContent)
}

@Test
fun testPluginWithUnavailableVersionCatalog() {
versionCatalogFilePath.deleteIfExists()

buildFilePath.writeText(
"""
plugins {
id("io.github.pemistahl.version-catalog-linter")
}
""".trimIndent(),
)

val checkTaskResult =
GradleRunner.create()
.withProjectDir(projectDir)
.withPluginClasspath()
.withArguments("checkVersionCatalog")
.buildAndFail()

assertEquals(
TaskOutcome.FAILED,
checkTaskResult.task(":checkVersionCatalog")?.outcome,
)

assertTrue(
checkTaskResult.output.contains(
"An input file was expected to be present but it doesn't exist.",
),
)
}

private fun String.containsAll(elements: List<CharSequence>): Boolean {
return elements.all { this.contains(it) }
}
Expand Down

0 comments on commit 6d5958d

Please sign in to comment.