Skip to content

Commit

Permalink
replace dynamic properties with extension properties
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanKrueger committed Apr 3, 2012
1 parent 4b4c0a6 commit f2f965f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/main/groovy/com/trigonic/gradle/plugins/rpm/Rpm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class Rpm extends AbstractArchiveTask {

private <T extends Enum<T>> 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
}
}

Expand All @@ -84,8 +84,8 @@ class Rpm extends AbstractArchiveTask {
private <T, U> void aliasStaticInstances(Class<T> forClass, Class<U> 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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RpmPlugin implements Plugin<Project> {
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
Expand Down

0 comments on commit f2f965f

Please sign in to comment.