Skip to content

Commit 08ec972

Browse files
committed
Remove a little bit more of the internal shadow APIs
1 parent 8909d76 commit 08ec972

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package com.github.jrubygradle.jar
22

3-
import com.github.jengelman.gradle.plugins.shadow.internal.GradleVersionUtil
3+
/*
4+
* These two internal imports from the Shadow plugin are unavoidable because of
5+
* the expected internals of ShadowCopyAction
6+
*/
7+
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
813
import groovy.transform.PackageScope
14+
import org.apache.tools.zip.ZipOutputStream
915
import org.gradle.api.InvalidUserDataException
1016
import org.gradle.api.artifacts.Configuration
1117
import org.gradle.api.file.DuplicatesStrategy
@@ -15,6 +21,7 @@ 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
24+
import org.gradle.api.tasks.bundling.ZipEntryCompression
1825

1926
/**
2027
* JRubyJar creates a Java Archive with Ruby code packed inside of it.
@@ -240,7 +247,6 @@ class JRubyJar extends Jar {
240247
appendix = 'jruby'
241248
/* Make sure our default configuration is present regardless of whether we use it or not */
242249
prepareTask = project.task("prepare${prepareNameForSuffix(name)}", type: JRubyPrepare)
243-
versionUtil = new GradleVersionUtil(getProject().getGradle().getGradleVersion())
244250
dependsOn prepareTask
245251

246252
// TODO get rid of this and try to adjust the CopySpec for the gems
@@ -297,7 +303,6 @@ class JRubyJar extends Jar {
297303
[new JRubyDirInfoTransformer()], /* transformers */
298304
[], /* relocators */
299305
mainSpec.buildRootResolver().getPatternSet(), /* patternSet */
300-
versionUtil, /* util */
301306
false, /* preserveFileTimestamps */
302307
false, /* minimizeJar */
303308
null /* unusedTracker */
@@ -307,7 +312,14 @@ class JRubyJar extends Jar {
307312

308313
@Internal
309314
protected ZipCompressor getInternalCompressor() {
310-
return versionUtil.getInternalCompressor(getEntryCompression(), this)
315+
switch (entryCompression) {
316+
case ZipEntryCompression.DEFLATED:
317+
return new DefaultZipCompressor(this.zip64, ZipOutputStream.DEFLATED)
318+
case ZipEntryCompression.STORED:
319+
return new DefaultZipCompressor(this.zip64, ZipOutputStream.STORED)
320+
default:
321+
throw new IllegalArgumentException(String.format('Unknown Compression type %s', entryCompression))
322+
}
311323
}
312324

313325
/**
@@ -329,5 +341,4 @@ class JRubyJar extends Jar {
329341
protected String embeddedJRubyMainsVersion = DEFAULT_JRUBY_MAINS
330342
protected String jarConfiguration = DEFAULT_JRUBYJAR_CONFIG
331343
protected String jarMainClass
332-
protected GradleVersionUtil versionUtil
333344
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package com.github.jrubygradle.jar.internal
77
*/
88

99
import com.github.jengelman.gradle.plugins.shadow.impl.RelocatorRemapper
10-
import com.github.jengelman.gradle.plugins.shadow.internal.GradleVersionUtil
1110
import com.github.jengelman.gradle.plugins.shadow.internal.UnusedTracker
1211
import com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor
1312
import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
@@ -33,6 +32,7 @@ import org.gradle.api.internal.file.copy.CopyAction
3332
import org.gradle.api.internal.file.copy.CopyActionProcessingStream
3433
import org.gradle.api.internal.file.copy.FileCopyDetailsInternal
3534
import org.gradle.api.tasks.WorkResult
35+
import org.gradle.api.tasks.WorkResults
3636
import org.gradle.api.tasks.bundling.Zip
3737
import org.gradle.api.tasks.util.PatternSet
3838
import org.gradle.internal.UncheckedException
@@ -69,14 +69,13 @@ class JRubyJarCopyAction implements CopyAction {
6969
private final List<Relocator> relocators
7070
private final PatternSet patternSet
7171
private final String encoding
72-
private final GradleVersionUtil versionUtil
7372
private final boolean preserveFileTimestamps
7473
private final boolean minimizeJar
7574
private final UnusedTracker unusedTracker
7675

7776
JRubyJarCopyAction(File zipFile, ZipCompressor compressor, DocumentationRegistry documentationRegistry,
7877
String encoding, List<Transformer> transformers, List<Relocator> relocators,
79-
PatternSet patternSet, GradleVersionUtil util,
78+
PatternSet patternSet,
8079
boolean preserveFileTimestamps, boolean minimizeJar, UnusedTracker unusedTracker) {
8180

8281
this.zipFile = zipFile
@@ -86,7 +85,6 @@ class JRubyJarCopyAction implements CopyAction {
8685
this.relocators = relocators
8786
this.patternSet = patternSet
8887
this.encoding = encoding
89-
this.versionUtil = util
9088
this.preserveFileTimestamps = preserveFileTimestamps
9189
this.minimizeJar = minimizeJar
9290
this.unusedTracker = unusedTracker
@@ -141,7 +139,7 @@ class JRubyJarCopyAction implements CopyAction {
141139
)
142140
}
143141
}
144-
return versionUtil.getWorkResult(true)
142+
return WorkResults.didWork(true)
145143
}
146144

147145
private void processTransformers(ZipOutputStream stream) {

0 commit comments

Comments
 (0)