RRZE – Projekte & Prozesse (P&P)

Das Blog der RRZE Stabsstelle "Projekte & Prozesse"

Content

Grails Plugins – lokal und global / Grails Plugins – local and global

English Version

Bei der Verwaltung von Grails Plugins in einem zentralen Repository gestaltet sich die lokale Weiterentwicklung der Plugins ggf. schwierig.

Mit dem folgenden Code-Block in der BuildConfig.groovy kann mittels des Kommandozeilenparameters -Dlive=... eines, oder mit
Komma getrennt, mehrere Plugins lokal geladen werden.

Wichtig ist dabei, dass neben dem Hauptprojekt auch alle Plugins mit diesem Code Block ausgestattet werden. So werden auch transitive Abhängigkeiten wie gewünscht mittels relativem Pfad oder aus dem Repository aufgelöst.

[groovy]
/*
* PPSA PLUGIN CONFIGURATION
*/
def runtimePlugins = [
“:ppsa-menu:latest.release”,
“:ppsa-layout:latest.release”,
]

/* —– BEGIN: no changes past here —– */
def live = System.getProperty(“live”)?System.getProperty(“live”).split(‘,’):[]
def filteredLivePlugins = []
if (live) {
filteredLivePlugins = live.inject([]) { list, lib ->
runtimePlugins.grep { it.contains(lib) } ? list << lib : list
}
if (filteredLivePlugins) {
println “[YOUR_PROJECT_NAME_HERE] Loading some plugins from relative paths in the workspace: ” + filteredLive
filteredLivePlugins.each { pluginName -> grails.plugin.location.”${pluginName}” = “../${pluginName}” }
}
}
/* —– END: no changes past here —– */

grails.project.dependency.resolution = {
plugins {
def filteredRuntimePlugins = runtimePlugins.inject([]) { list, lib ->
filteredLivePlugins.grep { lib.contains(it) } ? list : list << lib
}
if (filteredRuntimePlugins) {
println “[YOUR_PROJECT_NAME_HERE] Loading plugins from release repository: ” + filteredRuntimePlugins
filteredRuntimePlugins.each { pluginDef -> runtime “${pluginDef}” }
}
}
}
[/groovy]

Beispiel, wie man zur live Umgebung für das Plugin ppsa-layout wechseln kann:
[bash]
grails clean -Dlive=ppsa-layout
grails run-app -Dlive=ppsa-layout
[/bash]

Grails Plugins – local and global


With the management of Grails Plugins in a central repository the local further development of plugins could become quite difficult.

With the following Code Block in the  BuildConfig.groovy one or more plugins — sepearted via commas — can be loaded locally instead of from the repository with the help of the command line parameter  -Dlive=....

In order to also resolve transitive dependencies in this way it is important that beside the main project all plugins are also provided with this code block. This way also transitive dependencies can be loaded from a relative path or from the repository.

[groovy]
/*
* PPSA PLUGIN CONFIGURATION
*/
def runtimePlugins = [
“:ppsa-menu:latest.release”,
“:ppsa-layout:latest.release”,
]

/* —– BEGIN: no changes past here —– */
def live = System.getProperty(“live”)?System.getProperty(“live”).split(‘,’):[]
def filteredLivePlugins = []
if (live) {
filteredLivePlugins = live.inject([]) { list, lib ->
runtimePlugins.grep { it.contains(lib) } ? list << lib : list
}
if (filteredLivePlugins) {
println “[YOUR_PROJECT_NAME_HERE] Loading some plugins from relative paths in the workspace: ” + filteredLive
filteredLivePlugins.each { pluginName -> grails.plugin.location.”${pluginName}” = “../${pluginName}” }
}
}
/* —– END: no changes past here —– */

grails.project.dependency.resolution = {
plugins {
def filteredRuntimePlugins = runtimePlugins.inject([]) { list, lib ->
filteredLivePlugins.grep { lib.contains(it) } ? list : list << lib
}
if (filteredRuntimePlugins) {
println “[YOUR_PROJECT_NAME_HERE] Loading plugins from release repository: ” + filteredRuntimePlugins
filteredRuntimePlugins.each { pluginDef -> runtime “${pluginDef}” }
}
}
}
[/groovy]

Example on how to switch to the live environment for the plugin ppsa-layout:
[bash]
grails clean -Dlive=ppsa-layout
grails run-app -Dlive=ppsa-layout
[/bash]

Leave a comment

Your email address will not be published Required fields are marked *

You can use the following HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>