Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ You can also restart the wildfly after the deployment (and await it), analogous
```kotlin
reload = false // default for reload is true, so deactivate it first
restart = true
awaitRestart = true
awaitRestart = true
```

You can also deploy to WildFly in domain mode, but only one server group per task
Expand Down Expand Up @@ -108,14 +108,14 @@ task deployDomain(type: DeployWildflyTask) {
user = deploy.user
password = deploy.password
deploymentName = project.name
runtimeName = "${project.name}-${project.version}.war"
file = "$buildDir/libs/${project.name}-${project.version}.war"
runtimeName = tasks.war.archiveFileName
file = tasks.war.archiveFile
// redeploy if artifact with same name already deployed
undeployBeforehand = true
// server group of domain mode
domainServerGroup = "main-server-group"
// ask to restart servers after deploy instead of only reload them
restart = true
restart = true
reload = false
}
```
Expand Down Expand Up @@ -148,10 +148,10 @@ task("deploy", DeployWildflyTask::class) {
port = 9090
user = "mgmt_user"
password = "mgmt_password"
deploymentName = project.name //cli: --name=$runtimeName
runtimeName = "${project.name}-$version.war" //cli: --runtime-name=$runtimeName
// filepath, here a war example
file = "$buildDir/libs/${project.name}-$version.war".apply { println("file=$this") }
deploymentName.set(project.name) //cli: --name=$runtimeName
runtimeName.set(tasks.war.get().archiveFileName) //cli: --runtime-name=$runtimeName
// Using war.archiveFile will make the deploy task depend on the war task implicitly, no need for dependsOn("war")
file.set(tasks.war.get().archiveFile)
}
```

Expand Down Expand Up @@ -195,7 +195,7 @@ $ ./gradlew clean build publish

This will deploy the locally build plugin jar into your local maven repo and also into `build/lib`.

To use your locally build plugin you can just
To use your locally build plugin you can just
[override the plugin resolutionStrategy](https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_resolution_rules)
inside your settings.gradle(.kts) file.

Expand Down Expand Up @@ -229,7 +229,7 @@ pluginManagement {
repositories {
maven {
// this is the build folder of your local wildfly-deploy-gradle-plugin repository, you might need to adapt this
url = uri("build/lib")
url = uri("build/lib")
}
// or
mavenLocal()
Expand All @@ -239,4 +239,3 @@ pluginManagement {
}
}
```

13 changes: 7 additions & 6 deletions integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.3.21"
id("com.mkring.wildlydeplyplugin.deploy-wildfly-plugin") version "0.2.10"
id("com.mkring.wildlydeplyplugin.deploy-wildfly-plugin") version "0.2.12"
war
}
buildscript {
Expand Down Expand Up @@ -64,14 +64,15 @@ task("deploy", DeployWildflyTask::class) {
port = 9990
user = "mgmt"
password = "1234"
deploymentName = project.name
runtimeName = "${project.name}-$version.war"
file = "$buildDir/libs/${project.name}-$version.war".apply { println("file=$this") }
deploymentName.set(project.name)
runtimeName.set(tasks.war.get().archiveFileName)
// Using war.archiveFile will make the deploy task depend on the war task implicitly
file.set(tasks.war.get().archiveFile)
reload = false
dependsOn("build-id", "build", "war")
}
tasks.war {
dependsOn("build-id")
webInf {
from("build.id")
}
}
}
4 changes: 2 additions & 2 deletions integration/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pluginManagement {
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == "com.mkring.wildlydeplyplugin") {
useModule("com.mkring.wildlydeplyplugin:wildfly-deploy-gradle-plugin:0.2.10")
useModule("com.mkring.wildlydeplyplugin:wildfly-deploy-gradle-plugin:0.2.12")
}
}
}
repositories {
mavenLocal()
gradlePluginPortal()
}
}
}
23 changes: 13 additions & 10 deletions src/main/kotlin/com/mkring/wildlydeplyplugin/DeployWildflyPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package com.mkring.wildlydeplyplugin
import org.gradle.api.DefaultTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.TaskAction
import org.slf4j.LoggerFactory

Expand All @@ -17,16 +20,17 @@ open class DeployWildflyPlugin : Plugin<Project> {
open class DeployWildflyTask : DefaultTask() {
val log = LoggerFactory.getLogger(DeployWildflyTask::class.java)

@Input
var file: String? = null
@InputFile
val file: RegularFileProperty = project.objects.fileProperty()

@Input
var domainServerGroup: String = ""

@Input
var deploymentName: String? = null
val deploymentName: Property<String> = project.objects.property(String::class.java)

@Input
var runtimeName: String? = null
val runtimeName: Property<String> = project.objects.property(String::class.java)

@Input
var host: String = "localhost"
Expand Down Expand Up @@ -56,13 +60,12 @@ open class DeployWildflyTask : DefaultTask() {
init {
group = "help"
description = "Deploys files to a Wildfly und reloads it afterwards"
dependsOn("build")
outputs.upToDateWhen { false }
}

@TaskAction
fun deployWildfly() {
if (file == null || user == null || password == null) {
if (file.get().asFile.name.isEmpty() || user == null || password == null) {
log.error("DeployWildflyTask: missing configuration")
return
}
Expand All @@ -80,18 +83,18 @@ open class DeployWildflyTask : DefaultTask() {
if (awaitRestart && restart.not()) {
log.warn("awaitRestart is pointless if no restart is set")
}
log.info("deployWildfly: going to deploy $file to $host:$port")
log.info("deployWildfly: going to deploy ${file.get().asFile} to $host:$port")
try {
FileDeployer(
file,
file.get().asFile,
host,
port,
user,
password,
reload,
force,
deploymentName,
runtimeName,
deploymentName.get(),
runtimeName.get(),
domainServerGroup,
awaitReload,
undeployBeforehand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ open class ExecuteWildflyTask : DefaultTask() {
init {
group = "help"
description = "Executes cli commands on a Wildfly"
dependsOn("build")
outputs.upToDateWhen { false }
}

Expand All @@ -42,4 +41,4 @@ open class ExecuteWildflyTask : DefaultTask() {
throw e
}
}
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/com/mkring/wildlydeplyplugin/FileDeployer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.time.temporal.ChronoUnit
private val log = LoggerFactory.getLogger(FileDeployer::class.java)

class FileDeployer(
private val file: String?,
private val file: File,
private val host: String,
private val port: Int,
private val user: String?,
Expand Down Expand Up @@ -82,7 +82,7 @@ class FileDeployer(
""
}

val deploymentExists = File(file).isFile
val deploymentExists = file.isFile
log.debug("given $file existent: $deploymentExists")
if (deploymentExists.not()) throw IllegalStateException("couldn't find given deployment")

Expand Down