update to Gradle 5.1

This commit is contained in:
Jörg Prante 2019-01-11 15:01:39 +01:00
parent 3f21e9eff3
commit 19e2530a5e
44 changed files with 405 additions and 205 deletions

View file

@ -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'

View file

@ -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')}"

View file

@ -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)
}
/*

View file

@ -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<String> archiveFileNameProvider = new Callable<String>() {
@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<Object> 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<RegularFile> determineArchiveFile() {
Property<RegularFile> 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
}
}
}

View file

@ -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

View file

@ -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<String> 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

View file

@ -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

View file

@ -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:

View file

@ -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())

View file

@ -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()

View file

@ -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 {

View file

@ -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()
}

View file

@ -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<File> 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<String> calculateArguments(String... args) {
List<String> 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
}
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
import groovy.transform.Immutable

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm;
package org.xbib.gradle.plugin.test;
import org.gradle.api.GradleException

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
class DefaultGradleRunner implements GradleRunner {

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
class DependencyGraph {

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
import groovy.transform.Immutable

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
interface ExecutedTask {

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm;
package org.xbib.gradle.plugin.test;
interface ExecutionResult {

View file

@ -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()
}

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
interface GradleHandle {

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
interface GradleHandleBuildListener {

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
interface GradleHandleFactory {

View file

@ -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

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
import com.google.common.base.Predicate

View file

@ -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<String> calculateArguments(String... args) {
List<String> calculateArguments(String... args) {
List<String> 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.

View file

@ -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 {

View file

@ -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

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
import org.gradle.api.Project

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
interface PreExecutionAction {

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
class ProjectSpec extends AbstractProjectSpec {

View file

@ -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

View file

@ -1,4 +1,4 @@
package org.xbib.gradle.plugin.rpm
package org.xbib.gradle.plugin.test
/**
* Hold additional response data, that is only available

View file

@ -1,4 +1,3 @@
package org.xbib.gradle.plugin.rpm
import org.junit.Rule
import org.junit.rules.TestName

View file

@ -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

Binary file not shown.

View file

@ -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

2
gradlew vendored
View file

@ -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"

2
gradlew.bat vendored
View file

@ -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

View file

@ -444,6 +444,7 @@ public class RpmBuilder {
* @throws IllegalArgumentException if passed in character sequence contains dashes.
*/
private void checkVariableContainsIllegalChars(char[] illegalChars, CharSequence variable, String variableName) {
if (variable != null) {
for (int i = 0; i < variable.length(); i++) {
char currChar = variable.charAt(i);
for (char illegalChar : illegalChars) {
@ -454,6 +455,7 @@ public class RpmBuilder {
}
}
}
}
/**
* Required Field. Sets the package information, such as the rpm name, the version, and the release number.