Skip to content

Commit 4114794

Browse files
authored
Merge pull request #356 from rtyler/shadow-307
Sync JRubyJarCopyAction with the upstream/originating shadow code
2 parents 19487a8 + 08ec972 commit 4114794

File tree

4 files changed

+180
-80
lines changed

4 files changed

+180
-80
lines changed

jar-plugin/build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ generateTestConfig {
1717

1818
dependencies {
1919
compile project(':jruby-gradle-plugin')
20-
compile 'com.github.jengelman.gradle.plugins:shadow:[1.2.2,2.0)' // NEED TO FIX THIS OPEN END
20+
/*
21+
* NOTE: version 5.0.0 of the shadow plugin supports only Gradle 5.x and later
22+
*/
23+
compile 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
24+
compile 'org.codehaus.plexus:plexus-utils:[3.2.0,3.3)'
25+
compile 'org.apache.commons:commons-io:1.3.2'
26+
compile 'org.ow2.asm:asm-commons:[6.1,6.99)'
27+
compile 'org.apache.ant:ant:[1.10.6,2.0)'
2128

2229
testCompile (spockVersion) {
2330
exclude module : 'groovy-all'

jar-plugin/src/main/groovy/com/github/jrubygradle/jar/JRubyJar.groovy

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package com.github.jrubygradle.jar
22

3+
/*
4+
* These two internal imports from the Shadow plugin are unavoidable because of
5+
* the expected internals of ShadowCopyAction
6+
*/
37
import com.github.jengelman.gradle.plugins.shadow.internal.DefaultZipCompressor
48
import com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor
9+
510
import com.github.jrubygradle.JRubyPrepare
611
import com.github.jrubygradle.jar.internal.JRubyDirInfoTransformer
712
import com.github.jrubygradle.jar.internal.JRubyJarCopyAction
@@ -12,6 +17,7 @@ import org.gradle.api.artifacts.Configuration
1217
import org.gradle.api.file.DuplicatesStrategy
1318
import org.gradle.api.internal.file.copy.CopyAction
1419
import org.gradle.api.tasks.Input
20+
import org.gradle.api.tasks.Internal
1521
import org.gradle.api.tasks.Optional
1622
import org.gradle.api.tasks.StopExecutionException
1723
import org.gradle.api.tasks.bundling.Jar
@@ -293,11 +299,18 @@ class JRubyJar extends Jar {
293299
return new JRubyJarCopyAction(getArchivePath(),
294300
getInternalCompressor(),
295301
null, /* DocumentationRegistry */
302+
'utf-8', /* encoding */
296303
[new JRubyDirInfoTransformer()], /* transformers */
297304
[], /* relocators */
298-
mainSpec.buildRootResolver().getPatternSet())
305+
mainSpec.buildRootResolver().getPatternSet(), /* patternSet */
306+
false, /* preserveFileTimestamps */
307+
false, /* minimizeJar */
308+
null /* unusedTracker */
309+
)
310+
299311
}
300312

313+
@Internal
301314
protected ZipCompressor getInternalCompressor() {
302315
switch (entryCompression) {
303316
case ZipEntryCompression.DEFLATED:

jar-plugin/src/main/groovy/com/github/jrubygradle/jar/internal/JRubyDirInfoTransformer.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import java.nio.file.Files
44
import java.nio.file.Path
55
import java.nio.file.Paths
66

7-
import org.apache.tools.zip.ZipOutputStream
8-
import org.apache.tools.zip.ZipEntry
7+
import shadow.org.apache.tools.zip.ZipEntry
98
import org.codehaus.plexus.util.IOUtil
109
import org.gradle.api.file.FileTreeElement
1110

12-
import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
11+
import shadow.org.apache.tools.zip.ZipOutputStream
1312
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
13+
import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext
1414

1515
/**
1616
* JRubyDirInfoTransformer implements a {@link Transformer} interface.
@@ -44,7 +44,7 @@ class JRubyDirInfoTransformer implements Transformer {
4444
}
4545

4646
/** No-op since we don't transform the actual file */
47-
void transform(String path, InputStream is, List<Relocator> relocators) {
47+
void transform(TransformerContext context) {
4848
return
4949
}
5050

@@ -63,7 +63,7 @@ class JRubyDirInfoTransformer implements Transformer {
6363
* This method will also clean up our tempdir to make sure we don't
6464
* clutter the user's machine with junk
6565
*/
66-
void modifyOutputStream(ZipOutputStream os) {
66+
void modifyOutputStream(ZipOutputStream os, boolean preserveFileTimestamps) {
6767
processDirectory(os, tmpDir)
6868
deleteTempDirectory(tmpDir)
6969
}

0 commit comments

Comments
 (0)