-
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.
Creates github release convention (#13)
* Creates github release convention * Fixes apiEndpoint
- Loading branch information
Showing
7 changed files
with
127 additions
and
1 deletion.
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
16 changes: 16 additions & 0 deletions
16
conventions/src/main/kotlin/com.github.kyhule.polyworld.build.github-release.gradle.kts
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,16 @@ | ||
import com.github.kyhule.polyworld.build.PolyworldGithubReleaseExtension | ||
|
||
plugins { | ||
id("com.github.breadmoirai.github-release") | ||
} | ||
|
||
val extension = PolyworldGithubReleaseExtension.create(project) | ||
|
||
githubRelease { | ||
dryRun(extension.dryRun) | ||
token(extension.token) | ||
owner(extension.owner) | ||
releaseName { version.toString() } | ||
tagName { version.toString() } | ||
generateReleaseNotes { true } | ||
} |
22 changes: 22 additions & 0 deletions
22
...ions/src/main/kotlin/com/github/kyhule/polyworld/build/PolyworldGithubReleaseExtension.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 com.github.kyhule.polyworld.build | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.provider.Property | ||
import org.gradle.kotlin.dsl.create | ||
import org.gradle.kotlin.dsl.property | ||
import javax.inject.Inject | ||
|
||
open class PolyworldGithubReleaseExtension @Inject constructor( | ||
objects: ObjectFactory | ||
) { | ||
val dryRun: Property<Boolean> = objects.property<Boolean>().convention(false) | ||
val owner: Property<CharSequence> = objects.property<CharSequence>().convention("kyhule") | ||
val token: Property<CharSequence> = objects.property<CharSequence>().convention(System.getenv("GITHUB_TOKEN")) | ||
|
||
companion object { | ||
const val name = "polyworldGithubRelease" | ||
|
||
internal fun create(project: Project): PolyworldGithubReleaseExtension = project.extensions.create(name) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...est/kotlin/com/github/kyhule/polyworld/build/PolyworldGradlePluginPluginFunctionalTest.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,43 @@ | ||
/* | ||
* This Kotlin source file was generated by the Gradle 'init' task. | ||
*/ | ||
package com.github.kyhule.polyworld.build | ||
|
||
import java.io.File | ||
import kotlin.test.assertTrue | ||
import kotlin.test.Test | ||
import org.gradle.testkit.runner.GradleRunner | ||
import org.junit.jupiter.api.io.TempDir | ||
|
||
/** | ||
* A simple functional test for the 'com.github.kyhule.polyworld.build.greeting' plugin. | ||
*/ | ||
class PolyworldGradlePluginPluginFunctionalTest { | ||
|
||
@field:TempDir | ||
lateinit var projectDir: File | ||
|
||
private val buildFile by lazy { projectDir.resolve("build.gradle") } | ||
private val settingsFile by lazy { projectDir.resolve("settings.gradle") } | ||
|
||
@Test fun `can run task`() { | ||
// Set up the test build | ||
settingsFile.writeText("") | ||
buildFile.writeText(""" | ||
plugins { | ||
id('com.github.kyhule.polyworld.build.greeting') | ||
} | ||
""".trimIndent()) | ||
|
||
// Run the build | ||
val runner = GradleRunner.create() | ||
runner.forwardOutput() | ||
runner.withPluginClasspath() | ||
runner.withArguments("greeting") | ||
runner.withProjectDir(projectDir) | ||
val result = runner.build() | ||
|
||
// Verify the result | ||
assertTrue(result.output.contains("Hello from plugin 'com.github.kyhule.polyworld.build.greeting'")) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
plugin/src/main/kotlin/com/github/kyhule/polyworld/build/PolyworldGradlePluginPlugin.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,21 @@ | ||
/* | ||
* This Kotlin source file was generated by the Gradle 'init' task. | ||
*/ | ||
package com.github.kyhule.polyworld.build | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.Plugin | ||
|
||
/** | ||
* A simple 'hello world' plugin. | ||
*/ | ||
class PolyworldGradlePluginPlugin: Plugin<Project> { | ||
override fun apply(project: Project) { | ||
// Register a task | ||
project.tasks.register("greeting") { task -> | ||
task.doLast { | ||
println("Hello from plugin 'com.github.kyhule.polyworld.build.greeting'") | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
plugin/src/test/kotlin/com/github/kyhule/polyworld/build/PolyworldGradlePluginPluginTest.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 @@ | ||
/* | ||
* This Kotlin source file was generated by the Gradle 'init' task. | ||
*/ | ||
package com.github.kyhule.polyworld.build | ||
|
||
import org.gradle.testfixtures.ProjectBuilder | ||
import kotlin.test.Test | ||
import kotlin.test.assertNotNull | ||
|
||
/** | ||
* A simple unit test for the 'com.github.kyhule.polyworld.build.greeting' plugin. | ||
*/ | ||
class PolyworldGradlePluginPluginTest { | ||
@Test fun `plugin registers task`() { | ||
// Create a test project and apply the plugin | ||
val project = ProjectBuilder.builder().build() | ||
project.plugins.apply("com.github.kyhule.polyworld.build.greeting") | ||
|
||
// Verify the result | ||
assertNotNull(project.tasks.findByName("greeting")) | ||
} | ||
} |
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