From c413a25df790d60c728b9a710e6b7e7eb83cd184 Mon Sep 17 00:00:00 2001 From: Alan Krueger Date: Wed, 30 Jan 2013 10:44:17 -0600 Subject: [PATCH] address #18 by injecting a Directive.or metaclass method --- History.md | 5 +++++ README.md | 2 +- .../com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy | 7 ++++++- .../com/trigonic/gradle/plugins/rpm/RpmPluginTest.groovy | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 865bbae..ac85421 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +v1.4 - +================= + * issue #18: add syntactic sugar to easily combine file type + directives with a logical or (|) + v1.3 - 2013-01-08 ================= * bugfix: RPM_ARCH and RPM_OS were being added to the scripts in diff --git a/README.md b/README.md index 9db4143..81b848d 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ derived from RedHat. It leverages [Redline](http://redline-rpm.org/) Java libra fileMode = 0550 } from('src/main/resources') { - fileType = CONFIG + fileType = CONFIG | NOREPLACE into 'conf' } from('home') { diff --git a/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy b/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy index a903ddc..2cdda65 100644 --- a/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy +++ b/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy @@ -19,7 +19,8 @@ package com.trigonic.gradle.plugins.rpm import java.lang.reflect.Field import org.freecompany.redline.Builder -import org.gradle.api.Plugin; +import org.freecompany.redline.payload.Directive +import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.internal.file.copy.CopySpecImpl import org.gradle.api.plugins.BasePlugin @@ -43,5 +44,9 @@ class RpmPlugin implements Plugin { Builder.metaClass.getDefaultSourcePackage() { format.getLead().getName() + "-src.rpm" } + + Directive.metaClass.or = { Directive other -> + new Directive(delegate.flag | other.flag) + } } } \ No newline at end of file diff --git a/src/test/groovy/com/trigonic/gradle/plugins/rpm/RpmPluginTest.groovy b/src/test/groovy/com/trigonic/gradle/plugins/rpm/RpmPluginTest.groovy index f4f615f..58e36bd 100644 --- a/src/test/groovy/com/trigonic/gradle/plugins/rpm/RpmPluginTest.groovy +++ b/src/test/groovy/com/trigonic/gradle/plugins/rpm/RpmPluginTest.groovy @@ -71,7 +71,7 @@ class RpmPluginTest { from(srcDir.toString() + '/main/groovy') { createDirectoryEntry = true - fileType = CONFIG + fileType = CONFIG | NOREPLACE } from(noParentsDir) {