From f2f965f851f9873ffcf9752b86e372789d908fec Mon Sep 17 00:00:00 2001 From: Alan Krueger Date: Tue, 3 Apr 2012 16:37:57 -0500 Subject: [PATCH] replace dynamic properties with extension properties --- build.gradle | 2 +- .../groovy/com/trigonic/gradle/plugins/rpm/Rpm.groovy | 8 ++++---- .../trigonic/gradle/plugins/rpm/RpmCopySpecVisitor.groovy | 6 ++++-- .../com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 7cccb11..d240a2c 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ version = '1.0' def props = new Properties(); def localProperties = new File("local.properties") if (localProperties.exists()) localProperties.withInputStream { props.load(it) } -props.each { project.setProperty(it.key, it.value) } +props.each { project.ext.set it.key, it.value } configurations { deployerJars diff --git a/src/main/groovy/com/trigonic/gradle/plugins/rpm/Rpm.groovy b/src/main/groovy/com/trigonic/gradle/plugins/rpm/Rpm.groovy index 429407c..f8030f0 100755 --- a/src/main/groovy/com/trigonic/gradle/plugins/rpm/Rpm.groovy +++ b/src/main/groovy/com/trigonic/gradle/plugins/rpm/Rpm.groovy @@ -72,8 +72,8 @@ class Rpm extends AbstractArchiveTask { private > void aliasEnumValues(T[] values) { for (T value : values) { - assert !hasProperty(value.name()) - setProperty value.name(), value + assert !ext.hasProperty(value.name()) + ext.set value.name(), value } } @@ -84,8 +84,8 @@ class Rpm extends AbstractArchiveTask { private void aliasStaticInstances(Class forClass, Class ofClass) { for (Field field : forClass.fields) { if (field.type == ofClass && field.hasModifier(Modifier.STATIC)) { - assert !hasProperty(field.name) - setProperty field.name, field.get(null) + assert !ext.hasProperty(field.name) + ext.set field.name, field.get(null) } } } diff --git a/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmCopySpecVisitor.groovy b/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmCopySpecVisitor.groovy index 9983a0f..c9cfcba 100755 --- a/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmCopySpecVisitor.groovy +++ b/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmCopySpecVisitor.groovy @@ -78,14 +78,16 @@ class RpmCopySpecVisitor extends EmptyCopySpecVisitor { @Override void visitFile(FileVisitDetails fileDetails) { logger.debug "adding file {}", fileDetails.relativePath.pathString - builder.addFile "/" + fileDetails.relativePath.pathString, fileDetails.file, spec.fileMode, spec.fileType, spec.user ?: task.user, spec.group ?: task.group + builder.addFile "/" + fileDetails.relativePath.pathString, fileDetails.file, + spec.fileMode == null ? -1 : spec.fileMode, spec.fileType, spec.user ?: task.user, spec.group ?: task.group } @Override void visitDir(FileVisitDetails dirDetails) { if (spec.createDirectoryEntry) { logger.debug "adding directory {}", dirDetails.relativePath.pathString - builder.addDirectory "/" + dirDetails.relativePath.pathString, spec.dirMode, spec.fileType, spec.user ?: task.user, spec.group ?: task.group + builder.addDirectory "/" + dirDetails.relativePath.pathString, spec.dirMode == null ? -1 : spec.dirMode, + spec.fileType, spec.user ?: task.user, spec.group ?: task.group } } 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 2b8e1fa..77d40c8 100644 --- a/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy +++ b/src/main/groovy/com/trigonic/gradle/plugins/rpm/RpmPlugin.groovy @@ -28,7 +28,7 @@ class RpmPlugin implements Plugin { void apply(Project project) { project.plugins.apply(BasePlugin.class) - project.Rpm = Rpm.class + project.ext.Rpm = Rpm.class CopySpecImpl.metaClass.user = null CopySpecImpl.metaClass.group = null