Skip to content

Instantly share code, notes, and snippets.

View crc83's full-sized avatar

Sergiy Beley crc83

View GitHub Profile
@crc83
crc83 / gist:3e8da3e66c832a4b8eb0f490da188763
Created November 28, 2017 19:08
Split comma separated values -PdependenciesReleases=key1=value1,key2=value2
println "Checking if I need to update properties"
if ( project.hasProperty("dependenciesReleases") ) {
def dependenciesReleases = project.getProperty("dependenciesReleases")
def dependenciesMap = dependenciesReleases.split(',')
// Each list item is transformed
// to a Map entry with key/value.
.collectEntries { entry ->
def pair = entry.split('=')
[(pair.first()): pair.last()]
}
@crc83
crc83 / gist:6d3601b22bae0f8e92b1d8539b0a670b
Last active May 14, 2018 22:55
update property in properties file from gradle script
protected void writeVersion(File file, String key, version) {
if (!file.file) {
project.ant.echo(file: file, message: "$key=$version")
} else {
// we use replace here as other ant tasks escape and modify the whole file
project.ant.replaceregexp(file: file, byline: true) {
regexp(pattern: "^(\\s*)$key((\\s*[=|:]\\s*)|(\\s+)).+\$")
substitution(expression: "\\1$key\\2$version")
}
}

Hot Swapping With Maven, Jetty and IntelliJ

Based on Configuring Jetty, Maven, and Eclipse together with Hot Swap

I've always been a bit jealous when it comes to the Play! framework and the great dev mode they have for hot swapping classes at runtime. Jetty has a configuration setting, scanIntervalSeconds, that mimics this when working with a more traditional WAR, but does so by looking for changes to a file and restarting the server.

Fortunately, Jetty also provides the ability to rapidly test code with hot swapping. No more server restarts. The trick to getting hot swapping to work is to attach a remote debugger to your Jetty process. The following instructions outline how to do this in IntelliJ (tested with IDEA 10.5 CE).

Modify your jetty-maven-plugin to ignore the scan interval

  1. Open your pom and locate the plugins section