Compare commits
2 Commits
75c0405999
...
8af200bcdd
| Author | SHA1 | Date | |
|---|---|---|---|
| 8af200bcdd | |||
| 59662ac23a |
80
README.md
80
README.md
@@ -9,6 +9,17 @@
|
|||||||
* [Plugin Common Detekt.](#plugin-common-detekt)
|
* [Plugin Common Detekt.](#plugin-common-detekt)
|
||||||
* [Plugin Common Ktlint.](#plugin-common-ktlint)
|
* [Plugin Common Ktlint.](#plugin-common-ktlint)
|
||||||
* [Plugin Common Project.](#plugin-common-project)
|
* [Plugin Common Project.](#plugin-common-project)
|
||||||
|
* [Library.](#library)
|
||||||
|
* [Plugin Library.](#plugin-library)
|
||||||
|
* [Plugin Library Manifest.](#plugin-library-manifest)
|
||||||
|
* [Plugin Library publish.](#plugin-library-publish)
|
||||||
|
* [Service](#service)
|
||||||
|
* [Plugin Service](#plugin-service)
|
||||||
|
* [Plugin Service Container](#plugin-service-container)
|
||||||
|
* [Configuration](#configuration)
|
||||||
|
* [Gradle Tasks](#gradle-tasks)
|
||||||
|
* [Plugin Service Test Integration](#plugin-service-test-integration)
|
||||||
|
* [Plugin Service Process Resource](#plugin-service-process-resource)
|
||||||
* [Publish gradle plugin locally.](#publish-gradle-plugin-locally)
|
* [Publish gradle plugin locally.](#publish-gradle-plugin-locally)
|
||||||
* [Releasing gradle plugin.](#releasing-gradle-plugin)
|
* [Releasing gradle plugin.](#releasing-gradle-plugin)
|
||||||
* [Publish gradle plugin to repository.](#publish-gradle-plugin-to-repository)
|
* [Publish gradle plugin to repository.](#publish-gradle-plugin-to-repository)
|
||||||
@@ -49,6 +60,75 @@ id `ltd.lulz.plugin.common-plugin.common-project`
|
|||||||
|
|
||||||
Display project, Gradle, and Java information.
|
Display project, Gradle, and Java information.
|
||||||
|
|
||||||
|
### Library.
|
||||||
|
|
||||||
|
#### Plugin Library.
|
||||||
|
|
||||||
|
id `ltd.lulz.plugin.common-plugin.library`
|
||||||
|
|
||||||
|
Default setting and tasks for libraries.
|
||||||
|
|
||||||
|
#### Plugin Library Manifest.
|
||||||
|
|
||||||
|
id `ltd.lulz.plugin.common-plugin.library-manifest`
|
||||||
|
|
||||||
|
Extend manifest in library jar file.
|
||||||
|
|
||||||
|
#### Plugin Library publish.
|
||||||
|
|
||||||
|
id `ltd.lulz.plugin.common-plugin.library-publish`
|
||||||
|
|
||||||
|
Configuration for publishing project artifacts to a remote Maven repository.
|
||||||
|
|
||||||
|
### Service
|
||||||
|
|
||||||
|
#### Plugin Service
|
||||||
|
|
||||||
|
id `ltd.lulz.plugin.common-plugin.service`
|
||||||
|
|
||||||
|
Default setting and tasks for services.
|
||||||
|
|
||||||
|
#### Plugin Service Container
|
||||||
|
|
||||||
|
id `ltd.lulz.plugin.common-plugin.service-container`
|
||||||
|
|
||||||
|
Configuration for running project in docker locally during development.
|
||||||
|
|
||||||
|
##### Configuration
|
||||||
|
|
||||||
|
* properties `container.network`, environment `CONTAINER_NETWORK`, or default `develop`
|
||||||
|
* properties `container.port.expose`, environment `CONTAINER_PORT_EXPOSE`, or default `8080`
|
||||||
|
* properties `container.port.host`, environment `CONTAINER_PORT_HOST`, or default `8080`
|
||||||
|
* properties `container.profiles`, environment `CONTAINER_PROFILES`, or default `docker`
|
||||||
|
* properties `docker.port.expose`, environment `DOCKER_PORT_EXPOSE`, or default `8080`
|
||||||
|
|
||||||
|
container and docker ports can be a single port (e.g., 8080) or multiple ports separated by commas (e.g., 8080,8443)
|
||||||
|
|
||||||
|
##### Gradle Tasks
|
||||||
|
|
||||||
|
* `containerCreate` create docker container with network and spring boot profile.
|
||||||
|
* `containerStart` starts docker container.
|
||||||
|
* `containerStop` stops docker container.
|
||||||
|
* `containerNetworkCheck` check if network exist.
|
||||||
|
* `containerNetworkCreate` creates network.
|
||||||
|
* `containerNetworkRemove` removes network.
|
||||||
|
|
||||||
|
#### Plugin Service Test Integration
|
||||||
|
|
||||||
|
id `ltd.lulz.plugin.common-plugin.service-test-integration`
|
||||||
|
|
||||||
|
Adding task `testIntegration` to run integration test, add to `verification` group and add to task `check`.
|
||||||
|
|
||||||
|
Adding intellij support `src/test-integration/java`, `src/test-integration/kotlin`, and `src/test-integration/resources` as test module in intellij.
|
||||||
|
|
||||||
|
Adding dependencies support `testIntegrationImplementation()`, and `testIntegrationRuntimeOnly()` as part of Gradle.
|
||||||
|
|
||||||
|
#### Plugin Service Process Resource
|
||||||
|
|
||||||
|
id `ltd.lulz.plugin.common-plugin.service-process-resource`
|
||||||
|
|
||||||
|
Assign values to `application.yml` from Gradle.
|
||||||
|
|
||||||
## Publish gradle plugin locally.
|
## Publish gradle plugin locally.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation(aa.plugin.docker)
|
||||||
implementation(aa.plugin.core)
|
implementation(aa.plugin.core)
|
||||||
implementation(aa.plugin.detekt)
|
implementation(aa.plugin.detekt)
|
||||||
implementation(aa.plugin.ktlint)
|
implementation(aa.plugin.ktlint)
|
||||||
implementation(aa.plugin.kotlin)
|
implementation(aa.plugin.kotlin)
|
||||||
|
implementation(aa.plugin.springboot)
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Lulz Common Plugin"
|
description = "Lulz Common Plugin"
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
plugins {
|
||||||
|
id("ltd.lulz.plugin.core-plugin")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Jar>().configureEach {
|
||||||
|
manifest.attributes.apply {
|
||||||
|
put("Implementation-Title", project.name.split("-").joinToString(" "))
|
||||||
|
put("Implementation-Version", project.version)
|
||||||
|
put("Implementation-Vendor", info.vendorName)
|
||||||
|
put("Built-By", System.getProperty("user.name"))
|
||||||
|
put("Built-Git", "${git.currentBranch()} #${git.currentShortHash()}")
|
||||||
|
put("Built-Gradle", project.gradle.gradleVersion)
|
||||||
|
put("Built-JDK", System.getProperty("java.version"))
|
||||||
|
put("Built-OS", "${System.getProperty("os.name")} v${System.getProperty("os.version")}")
|
||||||
|
put("Built-Time", info.utcTimestamp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
plugins {
|
||||||
|
id("ltd.lulz.plugin.core-plugin")
|
||||||
|
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = uri("https://gitea.lulz.ltd/api/packages/aura-ascend/maven")
|
||||||
|
name = "GiteaPackages"
|
||||||
|
credentials {
|
||||||
|
username = config.find("repository.gitea.user", "REPOSITORY_USER")
|
||||||
|
password = config.find("repository.gitea.token", "REPOSITORY_TOKEN")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publications.register("mavenJava", MavenPublication::class) { from(components["java"]) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import org.springframework.boot.gradle.tasks.bundling.BootJar
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("ltd.lulz.plugin.common-plugin.common")
|
||||||
|
id("ltd.lulz.plugin.common-plugin.library-manifest")
|
||||||
|
id("ltd.lulz.plugin.common-plugin.library-publish")
|
||||||
|
id("org.springframework.boot")
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
named<Jar>("jar") {
|
||||||
|
archiveClassifier.set("")
|
||||||
|
}
|
||||||
|
withType<BootJar> {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
|
||||||
|
import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
|
||||||
|
import com.bmuschko.gradle.docker.tasks.container.DockerStopContainer
|
||||||
|
import com.bmuschko.gradle.docker.tasks.network.DockerCreateNetwork
|
||||||
|
import com.bmuschko.gradle.docker.tasks.network.DockerInspectNetwork
|
||||||
|
import com.bmuschko.gradle.docker.tasks.network.DockerRemoveNetwork
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("com.bmuschko.docker-spring-boot-application")
|
||||||
|
id("ltd.lulz.plugin.core-plugin")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun configurationPorts(
|
||||||
|
property: String,
|
||||||
|
environment: String,
|
||||||
|
): List<String> = config.findOrDefault(property, environment, "8080").split(',')
|
||||||
|
|
||||||
|
fun exposeDockerPorts(): List<Int> = configurationPorts("docker.port.expose", "DOCKER_PORT_EXPOSE")
|
||||||
|
.mapNotNull { it.toIntOrNull() }
|
||||||
|
|
||||||
|
fun exposeContainerPorts(): List<String> = configurationPorts("container.port.host", "CONTAINER_PORT_HOST")
|
||||||
|
.zip(configurationPorts("container.port.expose", "CONTAINER_PORT_EXPOSE"))
|
||||||
|
.map { (containerPort, exposedPort) -> "$containerPort:$exposedPort" }
|
||||||
|
|
||||||
|
docker.springBootApplication {
|
||||||
|
baseImage.set("eclipse-temurin:17-jre-alpine")
|
||||||
|
ports.set(exposeDockerPorts())
|
||||||
|
images.set(listOf("${project.name}:${project.version}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
register("containerCreate", DockerCreateContainer::class) {
|
||||||
|
group = "container"
|
||||||
|
targetImageId("${project.name}:${project.version}")
|
||||||
|
containerName.set(project.name)
|
||||||
|
hostConfig.autoRemove.set(true)
|
||||||
|
hostConfig.network.set(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
|
||||||
|
hostConfig.portBindings.set(exposeContainerPorts())
|
||||||
|
withEnvVar(
|
||||||
|
"SPRING_PROFILES_ACTIVE",
|
||||||
|
config.findOrDefault("container.profiles", "CONTAINER_PROFILES", "docker"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
register("containerStart", DockerStartContainer::class) {
|
||||||
|
group = "container"
|
||||||
|
dependsOn(findByPath("containerCreate"))
|
||||||
|
targetContainerId(project.name)
|
||||||
|
}
|
||||||
|
register("containerStop", DockerStopContainer::class) {
|
||||||
|
group = "container"
|
||||||
|
targetContainerId(project.name)
|
||||||
|
}
|
||||||
|
register("containerNetworkCheck", DockerInspectNetwork::class) {
|
||||||
|
group = "container"
|
||||||
|
targetNetworkId(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
|
||||||
|
onError { println("Network does not exist.") }
|
||||||
|
}
|
||||||
|
register("containerNetworkCreate", DockerCreateNetwork::class) {
|
||||||
|
group = "container"
|
||||||
|
networkName.set(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
|
||||||
|
}
|
||||||
|
register("containerNetworkRemove", DockerRemoveNetwork::class) {
|
||||||
|
group = "container"
|
||||||
|
targetNetworkId(config.findOrDefault("container.network", "CONTAINER_NETWORK", "develop"))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("ltd.lulz.plugin.core-plugin")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
withType<ProcessResources> {
|
||||||
|
val projectName = project.name
|
||||||
|
val projectVersion = project.version
|
||||||
|
filesMatching("**/application.yml") {
|
||||||
|
filter {
|
||||||
|
it.replace(
|
||||||
|
"%APP_NAME%",
|
||||||
|
projectName.split("-").joinToString(" ") { word -> word.uppercaseFirstChar() },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
filter { it.replace("%APP_VERSION%", projectVersion as String) }
|
||||||
|
filter { it.replace("%APP_BUILD_TIME%", info.utcTimestamp) }
|
||||||
|
filter { it.replace("%APP_BUILD_OS_NAME%", System.getProperty("os.name")) }
|
||||||
|
filter { it.replace("%APP_BUILD_OS_VERSION%", System.getProperty("os.version")) }
|
||||||
|
filter { it.replace("%APP_BUILD_GIT_COMMIT%", git.currentShortHash()) }
|
||||||
|
filter { it.replace("%APP_BUILD_GIT_BRANCH%", git.currentBranch()) }
|
||||||
|
}
|
||||||
|
onlyIf { file("src/main/resources/application.yml").exists() }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
plugins {
|
||||||
|
id("idea")
|
||||||
|
|
||||||
|
kotlin("jvm")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
fun DependencyHandler.testIntegrationImplementation(
|
||||||
|
dependencyNotation: Any,
|
||||||
|
): Dependency? = add("testIntegrationImplementation", dependencyNotation)
|
||||||
|
|
||||||
|
@Suppress("unused")
|
||||||
|
fun DependencyHandler.testIntegrationRuntimeOnly(
|
||||||
|
dependencyNotation: Any,
|
||||||
|
): Dependency? = add("testIntegrationRuntimeOnly", dependencyNotation)
|
||||||
|
|
||||||
|
sourceSets.create("test-integration") {
|
||||||
|
compileClasspath += sourceSets["main"].output
|
||||||
|
runtimeClasspath += sourceSets["main"].output
|
||||||
|
idea.module {
|
||||||
|
testSources.from(sourceSets["test-integration"].kotlin.srcDirs, sourceSets["test-integration"].java.srcDirs)
|
||||||
|
testResources.from(sourceSets["test-integration"].resources.srcDirs)
|
||||||
|
}
|
||||||
|
configurations.let {
|
||||||
|
it["testIntegrationImplementation"].extendsFrom(configurations.implementation.get())
|
||||||
|
it["testIntegrationRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
register<Test>("testIntegration") {
|
||||||
|
description = "Runs test integration."
|
||||||
|
group = "verification"
|
||||||
|
testClassesDirs = sourceSets["test-integration"].output.classesDirs
|
||||||
|
classpath = sourceSets["test-integration"].runtimeClasspath
|
||||||
|
}
|
||||||
|
check { dependsOn(getByName("testIntegration")) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
plugins {
|
||||||
|
id("ltd.lulz.plugin.common-plugin.common")
|
||||||
|
id("ltd.lulz.plugin.common-plugin.service-container")
|
||||||
|
id("ltd.lulz.plugin.common-plugin.service-process-resource")
|
||||||
|
id("ltd.lulz.plugin.common-plugin.service-test-integration")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user