Upgradle to Gradle 5.4.1 (#369)
- Replace Groovy `.collect` calls with `Transform.toList`.
This commit is contained in:
parent
c72b7e4930
commit
79941dc2a5
|
@ -131,6 +131,7 @@ class JRubyPrepareGemsIntegrationSpec extends IntegrationSpecification {
|
|||
tasks.addAll(moreTasks)
|
||||
tasks.add('-i')
|
||||
tasks.add('-s')
|
||||
tasks.add('--refresh-dependencies')
|
||||
writeBuildFile()
|
||||
gradleRunner(tasks).build()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
plugins {
|
||||
id 'com.gradle.build-scan' version '1.16'
|
||||
id 'com.gradle.build-scan' version '2.0.2'
|
||||
id 'org.ysb33r.gradletest' version '2.0-rc.4' apply false
|
||||
id 'com.jfrog.bintray' version '1.8.4' apply false
|
||||
id 'org.ajoberstar.github-pages' version '1.2.0' apply false
|
||||
|
|
|
@ -134,7 +134,7 @@ class GemUtils {
|
|||
* See:
|
||||
* https://gikhub.com/jruby-gradle/jruby-gradle-plugin/issues/341
|
||||
*/
|
||||
gemsToProcess.collect { it }.reverse().each { File gem ->
|
||||
gemsToProcess.toList().reverse().each { File gem ->
|
||||
args gem
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.jrubygradle.api.gems
|
||||
|
||||
import com.github.jrubygradle.internal.core.Transform
|
||||
import groovy.transform.CompileDynamic
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.util.logging.Slf4j
|
||||
|
@ -132,14 +133,14 @@ class GemVersion implements Comparable<GemVersion> {
|
|||
* @return List of GEM versions. Can be empty if all requirements evaluate to {@link #NO_VERSION}.
|
||||
*/
|
||||
static List<GemVersion> gemVersionsFromMultipleGemRequirements(String multipleRequirements) {
|
||||
multipleRequirements.split(/,\s*/).collect { String it ->
|
||||
Transform.toList(multipleRequirements.split(/,\s*/)) { String it ->
|
||||
gemVersionFromGemRequirement(it.trim())
|
||||
}.findAll {
|
||||
it != NO_VERSION
|
||||
}
|
||||
}
|
||||
|
||||
/** Takes a GEM requirement list and creates a single GEM versin, by taking a union of
|
||||
/** Takes a GEM requirement list and creates a single GEM version, by taking a union of
|
||||
* all requirements.
|
||||
*
|
||||
* @param multipleRequirements Comma-separated list of GEM requirements.
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.time.Instant
|
|||
|
||||
import static com.github.jrubygradle.api.gems.GemVersion.gemVersionFromGradleIvyRequirement
|
||||
import static com.github.jrubygradle.internal.core.IvyUtils.revisionsAsHtmlDirectoryListing
|
||||
import static java.nio.file.Files.getLastModifiedTime
|
||||
import static java.nio.file.Files.move
|
||||
import static java.nio.file.StandardCopyOption.ATOMIC_MOVE
|
||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING
|
||||
|
@ -110,7 +109,8 @@ abstract class AbstractIvyXmlProxyServer implements IvyXmlProxyServer {
|
|||
|
||||
protected boolean expired(Path ivyXml) {
|
||||
System.currentTimeMillis()
|
||||
Files.notExists(ivyXml) ||
|
||||
Path ivyXmlSha1 = ivyXml.resolveSibling("${ivyXml.toFile().name}.sha1")
|
||||
Files.notExists(ivyXml) || Files.notExists(ivyXmlSha1) ||
|
||||
(Files.getLastModifiedTime(ivyXml).toMillis() + EXPIRY_PERIOD_MILLIS < Instant.now().toEpochMilli())
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,8 @@ abstract class AbstractIvyXmlProxyServer implements IvyXmlProxyServer {
|
|||
if (inGroups(grp)) {
|
||||
Path ivyXml = getIvyXml(grp, name, version)
|
||||
ivyXml.resolveSibling("${ivyXml.toFile().name}.sha1")
|
||||
} else {
|
||||
throw new NotFound()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ class DefaultRubyGemRestApi implements com.github.jrubygradle.api.core.RubyGemQu
|
|||
)
|
||||
|
||||
if (jsonParser.dependencies?.runtime) {
|
||||
metadata.dependencies.addAll(jsonParser.dependencies.runtime.collect {
|
||||
metadata.dependencies.addAll( Transform.toList(jsonParser.dependencies.runtime) {
|
||||
new DefaultGemDependency(name: it.name, requirements: it.requirements)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.github.jrubygradle.internal.core
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
import java.util.function.Function
|
||||
import java.util.stream.Collectors
|
||||
|
||||
/** Transforms a collection to another collection.
|
||||
*
|
||||
* Deals with Groovy 2.4/2.5 backwards incompatibility.
|
||||
*
|
||||
* @author Schalk W. Cronjé
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
*/
|
||||
@CompileStatic
|
||||
class Transform {
|
||||
static <I,O> List<O> toList(final Collection<I> collection, Function<I,O> tx ) {
|
||||
collection.stream().map(tx).collect(Collectors.toList())
|
||||
}
|
||||
|
||||
static <I,O> List<O> toList(final I[] collection, Function<I,O> tx ) {
|
||||
collection.toList().stream().map(tx).collect(Collectors.toList())
|
||||
}
|
||||
|
||||
static <I,O> Set<O> toSet(final Collection<I> collection, Function<I,O> tx ) {
|
||||
collection.stream().map(tx).collect(Collectors.toSet())
|
||||
}
|
||||
|
||||
static <I,O> Set<O> toSet(final Iterable<I> collection, Function<I,O> tx ) {
|
||||
collection.toList().stream().map(tx).collect(Collectors.toSet())
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.github.jrubygradle.jar.internal
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.impl.RelocatorRemapper
|
||||
|
||||
/*
|
||||
* This source code is derived from Apache 2.0 licensed software copyright John
|
||||
* Engelman (https://github.com/johnrengelman) and was originally ported from this
|
||||
* repository: https://github.com/johnrengelman/shadow
|
||||
*/
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.impl.RelocatorRemapper
|
||||
import com.github.jengelman.gradle.plugins.shadow.internal.UnusedTracker
|
||||
import com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor
|
||||
import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
|
||||
|
@ -14,11 +15,6 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
|
|||
import groovy.util.logging.Slf4j
|
||||
import org.apache.commons.io.FilenameUtils
|
||||
import org.apache.commons.io.IOUtils
|
||||
import shadow.org.apache.tools.zip.UnixStat
|
||||
import shadow.org.apache.tools.zip.Zip64RequiredException
|
||||
import shadow.org.apache.tools.zip.ZipEntry
|
||||
import shadow.org.apache.tools.zip.ZipFile
|
||||
import shadow.org.apache.tools.zip.ZipOutputStream
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.UncheckedIOException
|
||||
|
@ -40,6 +36,11 @@ import org.objectweb.asm.ClassReader
|
|||
import org.objectweb.asm.ClassVisitor
|
||||
import org.objectweb.asm.ClassWriter
|
||||
import org.objectweb.asm.commons.ClassRemapper
|
||||
import shadow.org.apache.tools.zip.UnixStat
|
||||
import shadow.org.apache.tools.zip.Zip64RequiredException
|
||||
import shadow.org.apache.tools.zip.ZipEntry
|
||||
import shadow.org.apache.tools.zip.ZipFile
|
||||
import shadow.org.apache.tools.zip.ZipOutputStream
|
||||
|
||||
import java.util.zip.ZipException
|
||||
|
||||
|
@ -58,7 +59,7 @@ import java.util.zip.ZipException
|
|||
*/
|
||||
@Slf4j
|
||||
@SuppressWarnings(['ParameterCount', 'CatchException', 'DuplicateStringLiteral',
|
||||
'CatchThrowable', 'VariableName', 'UnnecessaryGString', 'InvertedIfElse'])
|
||||
'CatchThrowable', 'VariableName', 'UnnecessaryGString', 'InvertedIfElse'])
|
||||
class JRubyJarCopyAction implements CopyAction {
|
||||
static final long CONSTANT_TIME_FOR_ZIP_ENTRIES = (new GregorianCalendar(1980, 1, 1, 0, 0, 0)).timeInMillis
|
||||
|
||||
|
@ -74,9 +75,9 @@ class JRubyJarCopyAction implements CopyAction {
|
|||
private final UnusedTracker unusedTracker
|
||||
|
||||
JRubyJarCopyAction(File zipFile, ZipCompressor compressor, DocumentationRegistry documentationRegistry,
|
||||
String encoding, List<Transformer> transformers, List<Relocator> relocators,
|
||||
PatternSet patternSet,
|
||||
boolean preserveFileTimestamps, boolean minimizeJar, UnusedTracker unusedTracker) {
|
||||
String encoding, List<Transformer> transformers, List<Relocator> relocators,
|
||||
PatternSet patternSet,
|
||||
boolean preserveFileTimestamps, boolean minimizeJar, UnusedTracker unusedTracker) {
|
||||
|
||||
this.zipFile = zipFile
|
||||
this.compressor = compressor
|
||||
|
@ -109,20 +110,13 @@ class JRubyJarCopyAction implements CopyAction {
|
|||
unusedClasses = Collections.emptySet()
|
||||
}
|
||||
|
||||
final ZipOutputStream zipOutStr
|
||||
|
||||
try {
|
||||
zipOutStr = compressor.createArchiveOutputStream(zipFile)
|
||||
} catch (Exception e) {
|
||||
throw new GradleException("Could not create ZIP '${zipFile.toString()}'", e)
|
||||
}
|
||||
|
||||
try {
|
||||
final ZipOutputStream zipOutStr = compressor.createArchiveOutputStream(zipFile)
|
||||
withResource(zipOutStr, new Action<ZipOutputStream>() {
|
||||
void execute(ZipOutputStream outputStream) {
|
||||
try {
|
||||
stream.process(new StreamAction(outputStream, encoding, transformers, relocators, patternSet,
|
||||
unusedClasses))
|
||||
unusedClasses))
|
||||
processTransformers(outputStream)
|
||||
} catch (Exception e) {
|
||||
log.error('ex', e)
|
||||
|
@ -134,10 +128,12 @@ class JRubyJarCopyAction implements CopyAction {
|
|||
} catch (UncheckedIOException e) {
|
||||
if (e.cause instanceof Zip64RequiredException) {
|
||||
throw new Zip64RequiredException(
|
||||
String.format("%s\n\nTo build this archive, please enable the zip64 extension.\nSee: %s",
|
||||
e.cause.message, documentationRegistry.getDslRefForProperty(Zip, "zip64"))
|
||||
String.format("%s\n\nTo build this archive, please enable the zip64 extension.\nSee: %s",
|
||||
e.cause.message, documentationRegistry.getDslRefForProperty(Zip, "zip64"))
|
||||
)
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new GradleException("Could not create ZIP '${zipFile.toString()}'", e)
|
||||
}
|
||||
return WorkResults.didWork(true)
|
||||
}
|
||||
|
@ -217,7 +213,7 @@ class JRubyJarCopyAction implements CopyAction {
|
|||
private final Set<String> visitedFiles = [] as Set
|
||||
|
||||
StreamAction(ZipOutputStream zipOutStr, String encoding, List<Transformer> transformers,
|
||||
List<Relocator> relocators, PatternSet patternSet, Set<String> unused) {
|
||||
List<Relocator> relocators, PatternSet patternSet, Set<String> unused) {
|
||||
this.zipOutStr = zipOutStr
|
||||
this.transformers = transformers
|
||||
this.relocators = relocators
|
||||
|
@ -260,7 +256,7 @@ class JRubyJarCopyAction implements CopyAction {
|
|||
|
||||
private boolean isUnused(String classPath) {
|
||||
final String className = FilenameUtils.removeExtension(classPath)
|
||||
.replace('/' as char, '.' as char)
|
||||
.replace('/' as char, '.' as char)
|
||||
final boolean result = unused.contains(className)
|
||||
if (result) {
|
||||
log.debug("Dropping unused class: $className")
|
||||
|
@ -354,11 +350,11 @@ class JRubyJarCopyAction implements CopyAction {
|
|||
try {
|
||||
String mappedPath = remapper.map(element.relativePath.pathString)
|
||||
transformers.find { it.canTransformResource(element) }.transform(
|
||||
TransformerContext.builder()
|
||||
.path(mappedPath)
|
||||
.is(is)
|
||||
.relocators(relocators)
|
||||
.build()
|
||||
TransformerContext.builder()
|
||||
.path(mappedPath)
|
||||
.is(is)
|
||||
.relocators(relocators)
|
||||
.build()
|
||||
)
|
||||
} finally {
|
||||
is.close()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.jrubygradle.war
|
||||
|
||||
import com.github.jrubygradle.internal.core.Transform
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.bundling.War
|
||||
|
@ -34,7 +35,7 @@ class JRubyWar extends War {
|
|||
// is only resolved at execution time. This will take the embeds
|
||||
// from within the `jrubyEmbeds` configuration and dump them into the war
|
||||
from {
|
||||
project.configurations.jrubyEmbeds.collect {
|
||||
Transform.toList(project.configurations.jrubyEmbeds) {
|
||||
project.zipTree(it)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue