diff --git a/build.gradle b/build.gradle index 5e7293b..7891d5d 100644 --- a/build.gradle +++ b/build.gradle @@ -19,11 +19,6 @@ printf "Date: %s\nHost: %s\nOS: %s %s %s\nJava: %s %s %s %s\nGradle: %s Groovy: System.getProperty("java.vm.name"), gradle.gradleVersion, GroovySystem.getVersion(), JavaVersion.current() -// our RPM gradle plugin integration test looks into Gradle's " Task : " output -if (VersionNumber.parse(gradle.gradleVersion).compareTo(VersionNumber.parse("4.8")) < 0) { - throw new GradleScriptException("Gradle version must be 4.8 or higher", null) -} - ext { user = 'xbib' projectName = 'rpm' diff --git a/gradle-plugin-rpm/build.gradle b/gradle-plugin-rpm/build.gradle index 2f8c62d..ab04047 100644 --- a/gradle-plugin-rpm/build.gradle +++ b/gradle-plugin-rpm/build.gradle @@ -13,10 +13,10 @@ apply plugin: 'com.gradle.plugin-publish' dependencies { compile gradleApi() compile project(':rpm-core') - compileOnly "org.codehaus.groovy:groovy-all:${project.property('groovy.version')}" + compileOnly "org.codehaus.groovy:groovy:${project.property('groovy.version')}" testCompile "junit:junit:${project.property('junit.version')}" testCompile("org.spockframework:spock-core:${project.property('spock-core.version')}") { - exclude module: 'groovy-all' + exclude module: 'groovy' exclude module: 'junit' } testCompile "org.xbib:guice:${project.property('xbib-guice.version')}" diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy index 03cc747..f78f101 100644 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/ProjectPackagingExtension.groovy @@ -34,8 +34,8 @@ class ProjectPackagingExtension extends SystemPackagingExtension { ProjectPackagingExtension(Project project) { FileResolver resolver = ((ProjectInternal) project).getFileResolver() - Instantiator instantiator = ((ProjectInternal) project).getServices().get(Instantiator.class) - delegateCopySpec = new DefaultCopySpec( resolver, instantiator) + Instantiator instantiator = ((ProjectInternal) project).getServices().get(Instantiator) + delegateCopySpec = new DefaultCopySpec(resolver, instantiator) } /* diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy index 1635b4a..f001a98 100755 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/Rpm.groovy @@ -1,9 +1,13 @@ package org.xbib.gradle.plugin.rpm +import groovy.util.logging.Log4j import org.gradle.api.file.FileCollection +import org.gradle.api.file.RegularFile import org.gradle.api.internal.ConventionMapping import org.gradle.api.internal.IConventionAware -import org.gradle.api.tasks.AbstractCopyTask +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.Optional @@ -11,17 +15,23 @@ import org.gradle.api.tasks.Nested import org.gradle.api.tasks.SkipWhenEmpty import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.bundling.AbstractArchiveTask +import org.gradle.util.GUtil import org.xbib.rpm.lead.Architecture import org.xbib.rpm.lead.Os import org.xbib.rpm.lead.PackageType +import javax.annotation.Nullable import java.nio.file.Path +import java.util.concurrent.Callable /** * */ +@Log4j class Rpm extends AbstractArchiveTask { + final ObjectFactory objectFactory + @Input @Optional Path changeLogFile @@ -34,12 +44,27 @@ class Rpm extends AbstractArchiveTask { Rpm() { super() + objectFactory = project.objects systemPackagingExtension = new SystemPackagingExtension() projectPackagingExtension = project.extensions.findByType(ProjectPackagingExtension) if (projectPackagingExtension) { getRootSpec().with(projectPackagingExtension.delegateCopySpec) } - extension = 'rpm' + archiveExtension.set('rpm') + + // override archive file name provider in Gradle 5 + Callable archiveFileNameProvider = new Callable() { + @Override + String call() throws Exception { + constructArchiveFile() + } + } + getArchiveFileName().set(getProject().provider(archiveFileNameProvider)) + } + + @Override + RpmCopyAction createCopyAction() { + new RpmCopyAction(this) } @Override @@ -51,7 +76,7 @@ class Rpm extends AbstractArchiveTask { } @Override - AbstractCopyTask from(Object... sourcePaths) { + Rpm from(Object... sourcePaths) { for (Object sourcePath : sourcePaths) { from(sourcePath, {}) } @@ -59,7 +84,7 @@ class Rpm extends AbstractArchiveTask { } @Override - AbstractCopyTask from(Object sourcePath, Closure c) { + Rpm from(Object sourcePath, Closure c) { def preserveSymlinks = FromConfigurationFactory.preserveSymlinks(this) use(CopySpecEnhancement) { getMainSpec().from(sourcePath, c << preserveSymlinks) @@ -68,7 +93,7 @@ class Rpm extends AbstractArchiveTask { } @Override - AbstractArchiveTask into(Object destPath, Closure configureClosure) { + Rpm into(Object destPath, Closure configureClosure) { use(CopySpecEnhancement) { getMainSpec().into(destPath, configureClosure) } @@ -76,7 +101,7 @@ class Rpm extends AbstractArchiveTask { } @Override - AbstractCopyTask exclude(Closure excludeSpec) { + Rpm exclude(Closure excludeSpec) { use(CopySpecEnhancement) { getMainSpec().exclude(excludeSpec) } @@ -84,7 +109,7 @@ class Rpm extends AbstractArchiveTask { } @Override - AbstractCopyTask filter(Closure closure) { + Rpm filter(Closure closure) { use(CopySpecEnhancement) { getMainSpec().filter(closure) } @@ -92,24 +117,13 @@ class Rpm extends AbstractArchiveTask { } @Override - AbstractCopyTask rename(Closure closure) { + Rpm rename(Closure closure) { use(CopySpecEnhancement) { getMainSpec().rename(closure) } this } - @Override - RpmCopyAction createCopyAction() { - new RpmCopyAction(this) - } - - @Input - @Optional - void setArch(Object arch) { - setArchStr((arch instanceof Architecture)?arch.name():arch.toString()) - } - @Input @Optional List getAllConfigurationPaths() { @@ -243,14 +257,14 @@ class Rpm extends AbstractArchiveTask { ConventionMapping mapping = ((IConventionAware) this).getConventionMapping() mapping.map('packageName', { - projectPackagingExtension?.getPackageName()?:getBaseName() - }) - mapping.map('release', { - projectPackagingExtension?.getRelease()?:getClassifier() + projectPackagingExtension?.getPackageName()?:getArchiveBaseName().getOrNull()?:'test' }) mapping.map('version', { sanitizeVersion(projectPackagingExtension?.getVersion()?:project.getVersion().toString()) }) + mapping.map('release', { + projectPackagingExtension?.getRelease()?:'' + }) mapping.map('epoch', { projectPackagingExtension?.getEpoch()?:0 }) @@ -327,40 +341,33 @@ class Rpm extends AbstractArchiveTask { mapping.map('postUninstall', { projectPackagingExtension?.getPostUninstall() }) - mapping.map('archiveName', { - assembleArchiveName() - }) mapping.map('fileType', { projectPackagingExtension?.getFileType() }) mapping.map('addParentDirs', { projectPackagingExtension?.getAddParentDirs()?:true }) - mapping.map('archStr', { - projectPackagingExtension?.getArchStr()?:Architecture.NOARCH.name() + mapping.map('arch', { + projectPackagingExtension?.arch?:Architecture.NOARCH }) mapping.map('os', { - projectPackagingExtension?.getOs()?:Os.UNKNOWN + projectPackagingExtension?.os?:Os.UNKNOWN }) mapping.map('type', { - projectPackagingExtension?.getType()?:PackageType.BINARY + projectPackagingExtension?.type?:PackageType.BINARY }) mapping.map('prefixes', { projectPackagingExtension?.getPrefixes()?:[] }) - } - - String assembleArchiveName() { - String name = getPackageName() - name += getVersion() ? "-${getVersion()}" : '' - name += getRelease() ? "-${getRelease()}" : '' - name += getArchString() ? ".${getArchString()}" : '' - name += getExtension() ? ".${getExtension()}" : '' - name - } - - String getArchString() { - getArchStr()?.toLowerCase() + mapping.map('archiveName', { + constructArchiveFile() + }) + mapping.map('archivePath', { + determineArchivePath() + }) + mapping.map('archiveFile', { + determineArchiveFile() + }) } void prefixes(String... addPrefixes) { @@ -379,6 +386,26 @@ class Rpm extends AbstractArchiveTask { changeLogFile } + Provider determineArchiveFile() { + Property regularFile = objectFactory.fileProperty() + regularFile.set(new DestinationFile(new File(getDestinationDirectory().get().asFile.path, constructArchiveFile()))) + regularFile + } + + File determineArchivePath() { + determineArchiveFile().get().asFile + } + + String constructArchiveFile() { + String name = GUtil.elvis(getPackageName(), "") + name += maybe(name, '-', getVersion()) + name += maybe(name, '-', getRelease()) + name += maybe(name, '.', getArch().name().toLowerCase()) + String extension = archiveExtension.getOrNull() + name += GUtil.isTrue(extension) ? "." + extension : "" + name + } + static String sanitizeVersion(String version) { version.replaceAll(/\+.*/, '').replaceAll(/-/, '~') } @@ -390,4 +417,32 @@ class Rpm extends AbstractArchiveTask { return "unknown" } } + + static String maybe(@Nullable String prefix, String delimiter, @Nullable String value) { + if (GUtil.isTrue(value)) { + if (GUtil.isTrue(prefix)) { + return delimiter.concat(value) + } else { + return value + } + } + "" + } + + static class DestinationFile implements RegularFile { + private final File file + + DestinationFile(File file) { + this.file = file + } + + String toString() { + return this.file.toString() + } + + @Override + File getAsFile() { + return this.file + } + } } diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy index 2982b29..760a593 100755 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/RpmCopyAction.groovy @@ -15,7 +15,6 @@ import org.gradle.api.tasks.WorkResults import org.gradle.internal.UncheckedException import org.xbib.gradle.plugin.rpm.validation.RpmTaskPropertiesValidator import org.xbib.rpm.RpmBuilder -import org.xbib.rpm.lead.Architecture import org.xbib.rpm.header.HeaderTag import org.xbib.rpm.payload.Directive @@ -164,7 +163,7 @@ class RpmCopyAction implements CopyAction { builder = new RpmBuilder() builder.setPackage task.packageName, task.version, task.release, task.epoch builder.setType task.type - builder.setPlatform Architecture.valueOf(task.archStr.toUpperCase()), task.os + builder.setPlatform task.arch, task.os builder.setGroup task.packageGroup builder.setBuildHost task.buildHost builder.setSummary task.summary @@ -266,19 +265,20 @@ class RpmCopyAction implements CopyAction { } protected void end() { - Path path = task.getArchivePath().toPath() + Path path = task.archiveFile.get().asFile.toPath() + Files.createDirectories(path.parent) Files.newByteChannel(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING).withCloseable { ch -> builder.build(ch) } - logger.info 'Created RPM archive {}', path + logger.info 'created RPM archive {}', path } String standardScriptDefines() { includeStandardDefines ? String.format(" RPM_ARCH=%s \n RPM_OS=%s \n RPM_PACKAGE_NAME=%s \n RPM_PACKAGE_VERSION=%s \n RPM_PACKAGE_RELEASE=%s \n\n", - task.getArchString(), - task.os?.toString()?.toLowerCase() ?: '', + task.arch?.toString()?.toLowerCase()?:'', + task.os?.toString()?.toLowerCase()?: '', task.getPackageName(), task.getVersion(), task.getRelease()) : null diff --git a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy index 15031ab..4fc99a2 100755 --- a/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy +++ b/gradle-plugin-rpm/src/main/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtension.groovy @@ -75,13 +75,6 @@ class SystemPackagingExtension { @Input @Optional String sourcePackage - String archStr - - @Input @Optional - void setArch(Object arch) { - archStr = (arch instanceof Architecture) ? arch.name() : arch.toString() - } - @Input @Optional List fileType @@ -91,6 +84,14 @@ class SystemPackagingExtension { @Input @Optional Boolean addParentDirs + //String archStr + + @Input @Optional + Architecture arch + //void setArch(Object arch) { + // archStr = (arch instanceof Architecture) ? arch.name() : arch.toString() + //} + @Input @Optional Os os diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy index 73fa67a..131e6f1 100755 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmCopySpecVisitorTest.groovy @@ -2,6 +2,7 @@ package org.xbib.gradle.plugin.rpm import org.junit.Before import org.junit.Test +import org.xbib.gradle.plugin.test.ProjectSpec import static org.junit.Assert.assertEquals import static org.junit.Assert.assertTrue diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy index 4365d87..9a00c81 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginIntegrationTest.groovy @@ -1,5 +1,7 @@ package org.xbib.gradle.plugin.rpm +import org.xbib.gradle.plugin.test.IntegrationSpec + class RpmPluginIntegrationTest extends IntegrationSpec { def "rpm task is marked up-to-date when setting arch or os property"() { @@ -10,8 +12,8 @@ apply plugin: 'org.xbib.gradle.plugin.rpm' task buildRpm(type: Rpm) { packageName = 'rpmIsUpToDate' - arch = NOARCH - os = LINUX + arch = org.xbib.rpm.lead.Architecture.NOARCH + os = org.xbib.rpm.lead.Os.LINUX } ''' when: diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy index 6ef5914..91fbff7 100755 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/RpmPluginTest.groovy @@ -4,12 +4,13 @@ import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.plugins.BasePlugin import org.gradle.testfixtures.ProjectBuilder -import org.xbib.rpm.lead.Architecture +import org.xbib.gradle.plugin.test.DependencyGraph +import org.xbib.gradle.plugin.test.GradleDependencyGenerator +import org.xbib.gradle.plugin.test.ProjectSpec import org.xbib.rpm.format.Flags import org.xbib.rpm.header.Header -import org.xbib.rpm.lead.Os -import org.xbib.rpm.lead.PackageType import org.xbib.rpm.signature.SignatureTag +import spock.lang.Ignore import spock.lang.Unroll import java.nio.file.Files @@ -49,9 +50,9 @@ class RpmPluginTest extends ProjectSpec { packageName = 'bleah' version = '1.0' release = '1' - type = PackageType.BINARY - arch = Architecture.I386.name() - os = Os.LINUX + type = org.xbib.rpm.lead.PackageType.BINARY + arch = org.xbib.rpm.lead.Architecture.I386 + os = org.xbib.rpm.lead.Os.LINUX permissionGroup = 'Development/Libraries' summary = 'Bleah blarg' packageDescription = 'Not a very interesting library.' @@ -80,7 +81,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def result = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -108,8 +109,7 @@ class RpmPluginTest extends ProjectSpec { Project project = ProjectBuilder.builder().build() File buildDir = project.buildDir - - File srcDir = new File(projectDir, 'src') + File srcDir = new File(buildDir, 'src') srcDir.mkdirs() String fruit = 'apple' new File(srcDir, fruit).withWriter { out -> @@ -143,7 +143,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def result = RpmReader.read(project.file('build/tmp/ObsoletesConflictsTest/testing-1.2-3.i386.rpm').toPath()) @@ -193,7 +193,7 @@ class RpmPluginTest extends ProjectSpec { 'projectNameDefault' == project.buildRpm.packageName when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: noExceptionThrown() @@ -204,8 +204,8 @@ class RpmPluginTest extends ProjectSpec { when: project.apply plugin: 'org.xbib.gradle.plugin.rpm' project.task([type: Rpm], 'buildRpm', {}) - project.tasks.buildRpm.execute() - project.tasks.clean.execute() + project.tasks.buildRpm.copy() + //project.tasks.clean.execute() then: noExceptionThrown() } @@ -238,7 +238,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def files = RpmReader.read(rpmTask.getArchivePath().toPath()).files @@ -266,7 +266,7 @@ class RpmPluginTest extends ProjectSpec { } when: - rpmTask.execute() + rpmTask.copy() then: def res = RpmReader.read(rpmTask.getArchivePath().toPath()) @@ -295,7 +295,7 @@ class RpmPluginTest extends ProjectSpec { 'foo' == project.buildRpm.packageName when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: noExceptionThrown() @@ -366,9 +366,8 @@ class RpmPluginTest extends ProjectSpec { into('/conf/defaults') } - // Execute when: - rpmTask.execute() + rpmTask.copy() then: // Evaluate response @@ -424,7 +423,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/userTest-2.0-2.i386.rpm').toPath()) @@ -480,7 +479,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/userTest-2.0-2.i386.rpm').toPath()) @@ -534,7 +533,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/userTest-2.0-2.i386.rpm').toPath()) @@ -594,7 +593,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) @@ -627,7 +626,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) @@ -660,7 +659,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) @@ -695,7 +694,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/one-prefix-1.0-1.i386.rpm').toPath()) @@ -728,7 +727,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/multi-prefix-1.0-1.i386.rpm').toPath()) @@ -762,7 +761,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def scan = RpmReader.read(project.file('build/tmp/RpmPluginTest/multi-prefix-1.0-1.i386.rpm').toPath()) @@ -802,7 +801,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -849,7 +848,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -878,7 +877,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -912,7 +911,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - rpmTask.execute() + rpmTask.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/has-epoch-1.0-1.i386.rpm').toPath()) @@ -936,7 +935,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -964,7 +963,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -1011,7 +1010,7 @@ class RpmPluginTest extends ProjectSpec { } } - task.execute() + task.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -1019,9 +1018,10 @@ class RpmPluginTest extends ProjectSpec { res.files*.type == [DIR, DIR, SYMLINK, DIR, FILE] } + @Ignore def "Does not throw UnsupportedOperationException when copying external artifact with createDirectoryEntry option"() { given: - String testCoordinates = 'com.netflix.nebula:a:1.0.0' + String testCoordinates = 'org.xbib:foobar:1.0.0' DependencyGraph graph = new DependencyGraph([testCoordinates]) File reposRootDir = new File(project.buildDir, 'repos') GradleDependencyGenerator generator = new GradleDependencyGenerator(graph, reposRootDir.absolutePath) @@ -1055,7 +1055,7 @@ class RpmPluginTest extends ProjectSpec { } when: - rpmTask.execute() + rpmTask.copy() then: noExceptionThrown() @@ -1076,7 +1076,7 @@ class RpmPluginTest extends ProjectSpec { } when: - rpmTask.execute() + rpmTask.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()) @@ -1104,7 +1104,7 @@ class RpmPluginTest extends ProjectSpec { } when: - rpmTask.execute() + rpmTask.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()) @@ -1139,7 +1139,7 @@ class RpmPluginTest extends ProjectSpec { } when: - rpmTask.execute() + rpmTask.copy() then: Header header = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()).format.header @@ -1180,7 +1180,7 @@ class RpmPluginTest extends ProjectSpec { } when: - rpmTask.execute() + rpmTask.copy() then: Header header = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0.noarch.rpm').toPath()).format.header @@ -1200,7 +1200,7 @@ class RpmPluginTest extends ProjectSpec { packageName = 'semvertest' }) - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() expect: project.file("build/tmp/RpmPluginTest/semvertest-${expected}.noarch.rpm").exists() @@ -1227,7 +1227,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/providesTest-1.0.noarch.rpm').toPath()) @@ -1260,7 +1260,7 @@ class RpmPluginTest extends ProjectSpec { }) when: - project.tasks.buildRpm.execute() + project.tasks.buildRpm.copy() then: def res = RpmReader.read(project.file('build/tmp/RpmPluginTest/bleah-1.0-1.i386.rpm').toPath()) @@ -1283,7 +1283,7 @@ class RpmPluginTest extends ProjectSpec { Rpm rpmTask = project.task([type: Rpm], 'buildRpm', { from 'bin' }) - rpmTask.execute() + rpmTask.copy() then: def res = RpmReader.read(rpmTask.getArchivePath().toPath()) @@ -1306,7 +1306,7 @@ class RpmPluginTest extends ProjectSpec { into 'lib' } }) - rpmTask.execute() + rpmTask.copy() then: def res = RpmReader.read(rpmTask.getArchivePath().toPath()) diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy index a51c6bb..e415a9f 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/SystemPackagingExtensionTest.groovy @@ -2,8 +2,6 @@ package org.xbib.gradle.plugin.rpm import spock.lang.Specification -import java.nio.file.Paths - class SystemPackagingExtensionTest extends Specification { SystemPackagingExtension extension = new SystemPackagingExtension() diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy index 69c0718..a9997a1 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/validation/RpmTaskPropertiesValidatorIntegrationTest.groovy @@ -1,7 +1,7 @@ package org.xbib.gradle.plugin.rpm.validation import org.gradle.api.InvalidUserDataException -import org.xbib.gradle.plugin.rpm.ProjectSpec +import org.xbib.gradle.plugin.test.ProjectSpec import org.xbib.gradle.plugin.rpm.Rpm class RpmTaskPropertiesValidatorIntegrationTest extends ProjectSpec { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/AbstractProjectSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/AbstractProjectSpec.groovy similarity index 88% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/AbstractProjectSpec.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/AbstractProjectSpec.groovy index 76eba9f..4c37a41 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/AbstractProjectSpec.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/AbstractProjectSpec.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import org.gradle.api.Project import org.gradle.testfixtures.ProjectBuilder @@ -21,7 +21,7 @@ abstract class AbstractProjectSpec extends Specification { MultiProjectHelper helper void setup() { - ourProjectDir = new File("build/nebulatest/${this.class.canonicalName}/${testName.methodName.replaceAll(/\W+/, '-')}").absoluteFile + ourProjectDir = new File("build/xbibtest/${this.class.canonicalName}/${testName.methodName.replaceAll(/\W+/, '-')}").absoluteFile if (ourProjectDir.exists()) { ourProjectDir.deleteDir() } diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BaseIntegrationSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BaseIntegrationSpec.groovy new file mode 100644 index 0000000..efbe583 --- /dev/null +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BaseIntegrationSpec.groovy @@ -0,0 +1,192 @@ +package org.xbib.gradle.plugin.test + +import groovy.transform.CompileStatic +import groovy.transform.TypeCheckingMode +import org.gradle.api.logging.LogLevel +import org.junit.Rule +import org.junit.rules.TestName +import spock.lang.Specification + +abstract class BaseIntegrationSpec extends Specification { + @Rule + TestName testName = new TestName() + File projectDir + protected String moduleName + protected LogLevel logLevel = LogLevel.LIFECYCLE + protected List initScripts = [] + + private static final LOGGING_LEVEL_ENV_VARIABLE = "TEST_LOGGING_LEVEL" + + def setup() { + projectDir = new File("build/xbibtest/${this.class.canonicalName}/${testName.methodName.replaceAll(/\W+/, '-')}").absoluteFile + if (projectDir.exists()) { + projectDir.deleteDir() + } + projectDir.mkdirs() + moduleName = findModuleName() + } + + /** + * Override to alter its value + * @return + */ + protected LogLevel getLogLevel() { + String levelFromEnv = System.getenv(LOGGING_LEVEL_ENV_VARIABLE) + if(!levelFromEnv) { + return logLevel + } + return LogLevel.valueOf(levelFromEnv.toUpperCase()) + } + + /* Setup */ + + protected File directory(String path, File baseDir = getProjectDir()) { + new File(baseDir, path).with { + mkdirs() + it + } + } + + protected File file(String path, File baseDir = getProjectDir()) { + def splitted = path.split('/') + def directory = splitted.size() > 1 ? directory(splitted[0..-2].join('/'), baseDir) : baseDir + def file = new File(directory, splitted[-1]) + file.createNewFile() + file + } + + @CompileStatic(TypeCheckingMode.SKIP) + protected File createFile(String path, File baseDir = getProjectDir()) { + File file = file(path, baseDir) + if (!file.exists()) { + assert file.parentFile.mkdirs() || file.parentFile.exists() + file.createNewFile() + } + file + } + + protected static void checkForDeprecations(String output) { + def deprecations = output.readLines().findAll { + it.contains("has been deprecated and is scheduled to be removed in Gradle") || + it.contains("Deprecated Gradle features were used in this build") || + it.contains("has been deprecated. This is scheduled to be removed in Gradle") || + it.contains("This behaviour has been deprecated and is scheduled to be removed in Gradle") + } + // temporary for known issue with overwriting task + // overridden task expected to not be needed in future version + if (deprecations.size() == 1 && deprecations.first().contains("Creating a custom task named 'dependencyInsight' has been deprecated and is scheduled to be removed in Gradle 5.0.")) { + return + } + if (!System.getProperty("ignoreDeprecations") && !deprecations.isEmpty()) { + throw new IllegalArgumentException("Deprecation warnings were found (Set the ignoreDeprecations system property during the test to ignore):\n" + deprecations.collect { + " - $it" + }.join("\n")) + } + } + + protected static void checkForMutableProjectState(String output) { + def mutableProjectStateWarnings = output.readLines().findAll { + it.contains("was resolved without accessing the project in a safe manner") || + it.contains("This may happen when a configuration is resolved from a thread not managed by Gradle or from a different project") + + } + + if (!System.getProperty("ignoreMutableProjectStateWarnings") && !mutableProjectStateWarnings.isEmpty()) { + throw new IllegalArgumentException("Mutable Project State warnings were found (Set the ignoreMutableProjectStateWarnings system property during the test to ignore):\n" + mutableProjectStateWarnings.collect { + " - $it" + }.join("\n")) + } + } + + protected void writeHelloWorld(String packageDotted, File baseDir = getProjectDir()) { + def path = 'src/main/java/' + packageDotted.replace('.', '/') + '/HelloWorld.java' + def javaFile = createFile(path, baseDir) + javaFile << """\ + package ${packageDotted}; + + public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello Integration Test"); + } + } + """.stripIndent() + } + + /** + * Creates a unit test for testing your plugin. + * @param failTest true if you want the test to fail, false if the test should pass + * @param baseDir the directory to begin creation from, defaults to projectDir + */ + protected void writeUnitTest(boolean failTest, File baseDir = getProjectDir()) { + writeTest('src/test/java/', 'xbib', failTest, baseDir) + } + + /** + * + * Creates a unit test for testing your plugin. + * @param srcDir the directory in the project where the source file should be created. + * @param packageDotted the package for the unit test class, written in dot notation + * @param failTest true if you want the test to fail, false if the test should pass + * @param baseDir the directory to begin creation from, defaults to projectDir + */ + protected void writeTest(String srcDir, String packageDotted, boolean failTest, File baseDir = getProjectDir()) { + def path = srcDir + packageDotted.replace('.', '/') + '/HelloWorldTest.java' + def javaFile = createFile(path, baseDir) + javaFile << """\ + package ${packageDotted}; + import org.junit.Test; + import static org.junit.Assert.assertFalse; + + public class HelloWorldTest { + @Test public void doesSomething() { + assertFalse( $failTest ); + } + } + """.stripIndent() + } + + /** + * Creates a properties file to included as project resource. + * @param srcDir the directory in the project where the source file should be created. + * @param fileName to be used for the file, sans extension. The .properties extension will be added to the name. + * @param baseDir the directory to begin creation from, defaults to projectDir + */ + protected void writeResource(String srcDir, String fileName, File baseDir = getProjectDir()) { + def path = "$srcDir/${fileName}.properties" + def resourceFile = createFile(path, baseDir) + resourceFile.text = "firstProperty=foo.bar" + } + + protected void addResource(String srcDir, String filename, String contents, File baseDir = getProjectDir()) { + def resourceFile = createFile("${srcDir}/${filename}", baseDir) + resourceFile.text = contents + } + + protected String findModuleName() { + getProjectDir().getName().replaceAll(/_\d+/, '') + } + + protected List calculateArguments(String... args) { + List arguments = [] + // Gradle will use these files name from the PWD, instead of the project directory. It's easier to just leave + // them out and let the default find them, since we're not changing their default names. + //arguments += '--build-file' + //arguments += (buildFile.canonicalPath - projectDir.canonicalPath).substring(1) + //arguments += '--settings-file' + //arguments += (settingsFile.canonicalPath - projectDir.canonicalPath).substring(1) + //arguments += '--no-daemon' + switch (getLogLevel()) { + case LogLevel.INFO: + arguments += '--info' + break + case LogLevel.DEBUG: + arguments += '--debug' + break + } + arguments += '--stacktrace' + arguments += '-Dorg.gradle.warning.mode=all' + arguments.addAll(args) + arguments.addAll(initScripts.collect { file -> '-I' + file.absolutePath }) + arguments + } +} \ No newline at end of file diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/BuildLauncherBackedGradleHandle.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BuildLauncherBackedGradleHandle.groovy similarity index 98% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/BuildLauncherBackedGradleHandle.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BuildLauncherBackedGradleHandle.groovy index 72115bd..636f420 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/BuildLauncherBackedGradleHandle.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/BuildLauncherBackedGradleHandle.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import org.gradle.tooling.BuildException import org.gradle.tooling.BuildLauncher diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ClasspathAddingInitScriptBuilder.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathAddingInitScriptBuilder.groovy similarity index 98% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ClasspathAddingInitScriptBuilder.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathAddingInitScriptBuilder.groovy index 8b63db3..e90cc00 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ClasspathAddingInitScriptBuilder.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathAddingInitScriptBuilder.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import com.google.common.base.Function import com.google.common.base.Predicate diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ClasspathInjectingGradleHandleFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathInjectingGradleHandleFactory.groovy similarity index 97% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ClasspathInjectingGradleHandleFactory.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathInjectingGradleHandleFactory.groovy index 4736b23..b514b68 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ClasspathInjectingGradleHandleFactory.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ClasspathInjectingGradleHandleFactory.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm; +package org.xbib.gradle.plugin.test; import com.google.common.base.Predicate import org.gradle.util.GFileUtils diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/Coordinate.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/Coordinate.groovy similarity index 85% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/Coordinate.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/Coordinate.groovy index 21ec9f0..565f6b2 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/Coordinate.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/Coordinate.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import groovy.transform.Immutable diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DefaultExecutionResult.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultExecutionResult.groovy similarity index 98% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DefaultExecutionResult.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultExecutionResult.groovy index b0f5f9c..1210059 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DefaultExecutionResult.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultExecutionResult.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm; +package org.xbib.gradle.plugin.test; import org.gradle.api.GradleException diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DefaultGradleRunner.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultGradleRunner.groovy similarity index 95% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DefaultGradleRunner.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultGradleRunner.groovy index c9dda29..3d7dcc5 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DefaultGradleRunner.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DefaultGradleRunner.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test class DefaultGradleRunner implements GradleRunner { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DependencyGraph.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraph.groovy similarity index 97% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DependencyGraph.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraph.groovy index 86c6f81..f659676 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DependencyGraph.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraph.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test class DependencyGraph { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DependencyGraphNode.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraphNode.groovy similarity index 87% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DependencyGraphNode.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraphNode.groovy index baa12fb..ee3fcc8 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/DependencyGraphNode.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/DependencyGraphNode.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import groovy.transform.Immutable diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ExecutedTask.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutedTask.groovy similarity index 73% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ExecutedTask.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutedTask.groovy index 9ef5c89..986ae72 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ExecutedTask.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutedTask.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test interface ExecutedTask { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ExecutionResult.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutionResult.groovy similarity index 89% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ExecutionResult.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutionResult.groovy index f28b893..75df990 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ExecutionResult.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ExecutionResult.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm; +package org.xbib.gradle.plugin.test; interface ExecutionResult { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleDependencyGenerator.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleDependencyGenerator.groovy similarity index 65% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleDependencyGenerator.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleDependencyGenerator.groovy index 322d865..d15d343 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleDependencyGenerator.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleDependencyGenerator.groovy @@ -1,11 +1,10 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test class GradleDependencyGenerator { static final String STANDARD_SUBPROJECT_BLOCK = '''\ subprojects { apply plugin: 'maven-publish' - apply plugin: 'ivy-publish' apply plugin: 'java' publishing { @@ -13,24 +12,9 @@ class GradleDependencyGenerator { maven { url "../mavenrepo" } - ivy { - url "../ivyrepo" - layout('pattern') { - ivy '[organisation]/[module]/[revision]/[module]-[revision]-ivy.[ext]' - artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]' - m2compatible = true - } - } } publications { maven(MavenPublication) { - artifactId artifactName - - from components.java - } - ivy(IvyPublication) { - module artifactName - from components.java } } @@ -43,13 +27,11 @@ class GradleDependencyGenerator { DependencyGraph graph File gradleRoot - File ivyRepoDir File mavenRepoDir GradleDependencyGenerator(DependencyGraph graph, String directory = 'build/testrepogen') { this.graph = graph this.gradleRoot = new File(directory) - this.ivyRepoDir = new File(directory, 'ivyrepo') this.mavenRepoDir = new File(directory, 'mavenrepo') generateGradleFiles() } @@ -74,33 +56,6 @@ class GradleDependencyGenerator { """.stripIndent() } - File generateTestIvyRepo() { - runTasks('publishIvyPublicationToIvyRepository') - - ivyRepoDir - } - - String getIvyRepoDirPath() { - ivyRepoDir.absolutePath - } - - String getIvyRepoUrl() { - ivyRepoDir.toURI().toURL() - } - - String getIvyRepositoryBlock() { - """\ - ivy { - url '${getIvyRepoUrl()}' - layout('pattern') { - ivy '[organisation]/[module]/[revision]/[module]-[revision]-ivy.[ext]' - artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]' - m2compatible = true - } - } - """.stripIndent() - } - private void generateGradleFiles() { if (generated) { return @@ -138,9 +93,7 @@ class GradleDependencyGenerator { """\ group = '${node.group}' version = '${node.version}' - ext { - artifactName = '${node.artifact}' - } + ext { artifactName = '${node.artifact}' } """.stripIndent() + block.toString() } diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandle.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandle.groovy similarity index 81% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandle.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandle.groovy index b4bbd2d..e42bc3a 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandle.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandle.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test interface GradleHandle { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandleBuildListener.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleBuildListener.groovy similarity index 71% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandleBuildListener.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleBuildListener.groovy index 2e7ba93..619fc21 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandleBuildListener.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleBuildListener.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test interface GradleHandleBuildListener { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandleFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleFactory.groovy similarity index 83% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandleFactory.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleFactory.groovy index 57296d0..3a5851a 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleHandleFactory.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleHandleFactory.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test interface GradleHandleFactory { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleRunner.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunner.groovy similarity index 98% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleRunner.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunner.groovy index 4c22786..64eb3a8 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleRunner.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunner.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import com.google.common.base.Predicate import com.google.common.base.Predicates diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleRunnerFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunnerFactory.groovy similarity index 97% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleRunnerFactory.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunnerFactory.groovy index ff83cd5..c86e9db 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/GradleRunnerFactory.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/GradleRunnerFactory.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import com.google.common.base.Predicate diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/IntegrationSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/IntegrationSpec.groovy similarity index 97% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/IntegrationSpec.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/IntegrationSpec.groovy index 518b712..eb9b509 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/IntegrationSpec.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/IntegrationSpec.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import com.google.common.base.Predicate import org.gradle.api.logging.LogLevel @@ -38,7 +38,7 @@ abstract class IntegrationSpec extends BaseIntegrationSpec { protected Integer daemonMaxIdleTimeInSecondsInMemorySafeMode = DEFAULT_DAEMON_MAX_IDLE_TIME_IN_SECONDS_IN_MEMORY_SAFE_MODE - private String findModuleName() { + String findModuleName() { getProjectDir().getName().replaceAll(/_\d+/, '') } @@ -62,7 +62,7 @@ abstract class IntegrationSpec extends BaseIntegrationSpec { runner.handle(getProjectDir(), arguments, jvmArguments, preExecutionActions) } - private List calculateArguments(String... args) { + List calculateArguments(String... args) { List arguments = [] // Gradle will use these files name from the PWD, instead of the project directory. It's easier to just leave // them out and let the default find them, since we're not changing their default names. diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MinimalExecutedTask.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MinimalExecutedTask.groovy similarity index 80% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MinimalExecutedTask.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MinimalExecutedTask.groovy index 15cd8b1..f4d95b2 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MinimalExecutedTask.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MinimalExecutedTask.groovy @@ -1,4 +1,6 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test + +import org.xbib.gradle.plugin.test.ExecutedTask class MinimalExecutedTask implements ExecutedTask { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MultiProjectHelper.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectHelper.groovy similarity index 97% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MultiProjectHelper.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectHelper.groovy index da9361f..25cb884 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MultiProjectHelper.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectHelper.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import org.gradle.api.Project import org.gradle.testfixtures.ProjectBuilder diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MultiProjectInfo.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectInfo.groovy similarity index 79% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MultiProjectInfo.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectInfo.groovy index b580eba..1877291 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/MultiProjectInfo.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/MultiProjectInfo.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import org.gradle.api.Project diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/PreExecutionAction.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/PreExecutionAction.groovy similarity index 76% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/PreExecutionAction.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/PreExecutionAction.groovy index 167485d..6af4086 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/PreExecutionAction.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/PreExecutionAction.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test interface PreExecutionAction { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ProjectSpec.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ProjectSpec.groovy similarity index 74% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ProjectSpec.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ProjectSpec.groovy index 1112058..aff1cdf 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ProjectSpec.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ProjectSpec.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test class ProjectSpec extends AbstractProjectSpec { diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ToolingApiGradleHandleFactory.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingApiGradleHandleFactory.groovy similarity index 99% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ToolingApiGradleHandleFactory.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingApiGradleHandleFactory.groovy index d613d09..a750bfd 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ToolingApiGradleHandleFactory.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingApiGradleHandleFactory.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test import org.gradle.tooling.BuildLauncher import org.gradle.tooling.GradleConnector diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ToolingExecutionResult.groovy b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingExecutionResult.groovy similarity index 91% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ToolingExecutionResult.groovy rename to gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingExecutionResult.groovy index 2f881e9..1219641 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/ToolingExecutionResult.groovy +++ b/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/test/ToolingExecutionResult.groovy @@ -1,4 +1,4 @@ -package org.xbib.gradle.plugin.rpm +package org.xbib.gradle.plugin.test /** * Hold additional response data, that is only available diff --git a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/BaseIntegrationSpec.groovy b/gradle-plugin-rpm/src/test/resources/BaseIntegrationSpec.groovy similarity index 99% rename from gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/BaseIntegrationSpec.groovy rename to gradle-plugin-rpm/src/test/resources/BaseIntegrationSpec.groovy index 0d7cecf..604d1be 100644 --- a/gradle-plugin-rpm/src/test/groovy/org/xbib/gradle/plugin/rpm/BaseIntegrationSpec.groovy +++ b/gradle-plugin-rpm/src/test/resources/BaseIntegrationSpec.groovy @@ -1,4 +1,3 @@ -package org.xbib.gradle.plugin.rpm import org.junit.Rule import org.junit.rules.TestName diff --git a/gradle.properties b/gradle.properties index c65bde6..e8628cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ group = org.xbib name = rpm -version = 1.0.2 +version = 1.1.0 bouncycastle.version = 1.60 xbib-archive.version = 0.0.1 ant.version = 1.10.5 log4j.version = 2.11.1 # must match groovy version in gradle -groovy.version = 2.4.12 -spock-core.version = 1.1-groovy-2.4 +groovy.version = 2.5.4 +spock-core.version = 1.2-groovy-2.5 xbib-guice.version = 4.0.4 maven.version = 3.5.0 maven-plugin-annotations.version = 3.5 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 0d4a951..87b738c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 749f276..0066aae 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Aug 16 18:31:50 CEST 2018 +#Thu Jan 10 23:25:32 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-all.zip diff --git a/gradlew b/gradlew index cccdd3d..af6708f 100755 --- a/gradlew +++ b/gradlew @@ -28,7 +28,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" diff --git a/gradlew.bat b/gradlew.bat index e95643d..0f8d593 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java b/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java index a113fc6..9d8b7bc 100644 --- a/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java +++ b/rpm-core/src/main/java/org/xbib/rpm/RpmBuilder.java @@ -444,12 +444,14 @@ public class RpmBuilder { * @throws IllegalArgumentException if passed in character sequence contains dashes. */ private void checkVariableContainsIllegalChars(char[] illegalChars, CharSequence variable, String variableName) { - for (int i = 0; i < variable.length(); i++) { - char currChar = variable.charAt(i); - for (char illegalChar : illegalChars) { - if (currChar == illegalChar) { - throw new IllegalArgumentException(variableName + " with value: '" + variable + - "' contains illegal character " + currChar); + if (variable != null) { + for (int i = 0; i < variable.length(); i++) { + char currChar = variable.charAt(i); + for (char illegalChar : illegalChars) { + if (currChar == illegalChar) { + throw new IllegalArgumentException(variableName + " with value: '" + variable + + "' contains illegal character " + currChar); + } } } }