Compare commits

...

4 Commits

Author SHA1 Message Date
Schalk W. Cronjé 3a850814c1
Merge pull request #416 from jruby-gradle/master
Release 2.1.0-alpha.2
2020-11-15 21:24:35 +01:00
Schalk W. Cronjé 8320341dd5
Merge pull request #413 from ysb33r/alpha-2
Upgrade to grolifant 1.0.0-alpha.4
2020-11-15 21:23:35 +01:00
Schalk Cronje 102e880c3e Upgradle to grolifant 1.0.0-alpha.4 2020-11-15 18:01:39 +01:00
Schalk Cronje 8fd5b396e8 Upgrade to grolifant 1.0.0-alpha.2 2020-11-13 16:54:40 +01:00
12 changed files with 115 additions and 71 deletions

View File

@ -24,7 +24,7 @@
package com.github.jrubygradle
import com.github.jrubygradle.testhelper.IntegrationSpecification
import org.ysb33r.grolifant.api.OperatingSystem
import org.ysb33r.grolifant.api.core.OperatingSystem
import spock.lang.IgnoreIf
/**

View File

@ -256,7 +256,7 @@ class JRubyPluginExtension extends AbstractCombinedProjectTaskExtension {
registerPrepareTask(((Configuration) c).name)
break
case CharSequence:
this.gemConfiguration = project.provider(
this.gemConfiguration = projectOperations.provider(
{ -> configurations.getByName(c.toString()) } as Callable<Configuration>
)
registerPrepareTask(c.toString())

View File

@ -28,7 +28,7 @@ import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import org.gradle.api.InvalidUserDataException
import org.gradle.api.artifacts.Configuration
import org.ysb33r.grolifant.api.OperatingSystem
import org.ysb33r.grolifant.api.core.OperatingSystem
import org.ysb33r.grolifant.api.core.ProjectOperations
import org.ysb33r.grolifant.api.v4.StringUtils

View File

@ -24,7 +24,7 @@
package com.github.jrubygradle.internal
import org.gradle.api.InvalidUserDataException
import org.ysb33r.grolifant.api.OperatingSystem
import org.ysb33r.grolifant.api.core.OperatingSystem
import spock.lang.Issue
import spock.lang.Specification

View File

@ -54,8 +54,8 @@ subprojects {
dependencies {
compile localGroovy()
compile gradleApi()
compile "org.ysb33r.gradle:grolifant50:${grolifantVersion}"
gradleTestRuntime "org.ysb33r.gradle:grolifant50:${grolifantVersion}"
compile "org.ysb33r.gradle:grolifant60:${grolifantVersion}"
gradleTestRuntime "org.ysb33r.gradle:grolifant60:${grolifantVersion}"
}
codenarc {

View File

@ -136,7 +136,7 @@ abstract class AbstractJRubyPrepare extends DefaultTask implements JRubyAwareTas
void exec() {
File out = getOutputDir()
File jrubyJar = jrubyJarLocation.get()
extractGems(project, jrubyJar, gemsAsFileCollection(), out, SKIP)
extractGems(projectOperations, jrubyJar, gemsAsFileCollection(), out, SKIP)
dependencies.findAll {
it instanceof Configuration

View File

@ -34,7 +34,7 @@ import groovy.transform.CompileStatic
import groovy.transform.InheritConstructors
import groovy.transform.Synchronized
import groovy.util.logging.Slf4j
import org.ysb33r.grolifant.api.ExclusiveFileAccess
import org.ysb33r.grolifant.api.core.ExclusiveFileAccess
import java.nio.file.Files
import java.nio.file.Path

View File

@ -24,7 +24,7 @@
package com.github.jrubygradle.api.core
import com.github.jrubygradle.internal.core.DefaultRubyGemRestApi
import org.ysb33r.grolifant.api.Version
import org.ysb33r.grolifant.api.core.Version
import spock.lang.Specification
class RubyGemQueryRestApiSpec extends Specification {

View File

@ -25,9 +25,8 @@ task printSomePrettyOutputPlease(type: JRubyExec) {
script "${projectDir}/print-script.rb"
}
/*
* This task is only here for the execution fo the gradleTest
* This task is only here for the execution of the gradleTest
*/
task runGradleTest {
dependsOn printSomePrettyOutputPlease

View File

@ -1,4 +1,4 @@
version=2.1.0-alpha.1
version=2.1.0-alpha.2
group=com.github.jruby-gradle
copyrightYear=2014-2020
@ -14,7 +14,7 @@ releaseBuild=false
targetCompatibility=1.8
sourceCompatibility=1.8
grolifantVersion=1.0.0-alpha.1
grolifantVersion=1.0.0-alpha.4
jrubyVersion=9.2.9.0
jettyVersion=9.2.12.v20150709
bcprovVersion=1.46

View File

@ -23,28 +23,34 @@
*/
package com.github.jrubygradle.jar
import com.github.jengelman.gradle.plugins.shadow.internal.DefaultZipCompressor
import com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor
import com.github.jrubygradle.JRubyPrepare
/*
* These two internal imports from the Shadow plugin are unavoidable because of
* the expected internals of ShadowCopyAction
*/
import com.github.jengelman.gradle.plugins.shadow.internal.DefaultZipCompressor
import com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor
import com.github.jrubygradle.JRubyPrepare
import com.github.jrubygradle.jar.internal.JRubyDirInfoTransformer
import com.github.jrubygradle.jar.internal.JRubyJarCopyAction
import groovy.transform.CompileDynamic
import groovy.transform.PackageScope
import org.apache.tools.zip.ZipOutputStream
import org.gradle.api.InvalidUserDataException
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.file.RegularFile
import org.gradle.api.internal.file.copy.CopyAction
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.StopExecutionException
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.bundling.ZipEntryCompression
import org.ysb33r.grolifant.api.core.LegacyLevel
import org.ysb33r.grolifant.api.core.ProjectOperations
import static com.github.jrubygradle.JRubyPlugin.TASK_GROUP_NAME
@ -63,10 +69,31 @@ class JRubyJar extends Jar {
RUNNABLE, LIBRARY
}
static final String DEFAULT_JRUBYJAR_CONFIG = 'jrubyJar'
static final String DEFAULT_MAIN_CLASS = 'org.jruby.mains.JarMain'
static final String EXTRACTING_MAIN_CLASS = 'org.jruby.mains.ExtractingMain'
static final String DEFAULT_JRUBY_MAINS = '0.6.1'
public static final String DEFAULT_JRUBYJAR_CONFIG = 'jrubyJar'
public static final String DEFAULT_MAIN_CLASS = 'org.jruby.mains.JarMain'
public static final String EXTRACTING_MAIN_CLASS = 'org.jruby.mains.ExtractingMain'
public static final String DEFAULT_JRUBY_MAINS = '0.6.1'
JRubyJar() {
projectOperations = ProjectOperations.create(project)
addJrubyAppendix()
/* Make sure our default configuration is present regardless of whether we use it or not */
prepareTask = project.task("prepare${prepareNameForSuffix(name)}", type: JRubyPrepare)
prepareTask.group TASK_GROUP_NAME
dependsOn prepareTask
group TASK_GROUP_NAME
// TODO get rid of this and try to adjust the CopySpec for the gems
// to exclude '.jrubydir'
// there are other duplicates as well :(
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
customConfigName = "jrubyJarEmbeds-${hashCode()}"
project.afterEvaluate {
addJRubyDependency()
applyConfig()
}
}
/**
* @return Directory that the dependencies for this project will be staged into
@ -187,7 +214,7 @@ class JRubyJar extends Jar {
* Unrecognised values are silently discarded
*
* @param defs A list of defaults. Currently {@code gems} and {@code mainClass} are the only recognised values.
* @deprecated This method is no longer very useful, just use {@link defaultMainClass} instead
* @deprecated This method is no longer very useful, just use {@code defaultMainClass} instead
*/
@Deprecated
void defaults(final String... defs) {
@ -231,7 +258,7 @@ class JRubyJar extends Jar {
if (mainClass != null && scriptName != Type.LIBRARY) {
Configuration embeds = project.configurations.findByName(customConfigName)
with project.copySpec {
with projectOperations.copySpec {
embeds.each { File embed ->
logger.info("unzipping ${embed} in the jar")
/* We nede to extract the class files from jruby-mains in order to properly run */
@ -248,11 +275,11 @@ class JRubyJar extends Jar {
}
if (scriptName != Type.RUNNABLE && scriptName != Type.LIBRARY) {
File script = project.file(scriptName)
File script = projectOperations.file(scriptName)
if (!script.exists()) {
throw new InvalidUserDataException("initScript ${script} does not exists")
}
with project.copySpec {
with projectOperations.copySpec {
from script.parent
include script.name
rename(script.name, 'jar-bootstrap.rb')
@ -270,26 +297,6 @@ class JRubyJar extends Jar {
Type.RUNNABLE
}
JRubyJar() {
appendix = 'jruby'
/* Make sure our default configuration is present regardless of whether we use it or not */
prepareTask = project.task("prepare${prepareNameForSuffix(name)}", type: JRubyPrepare)
prepareTask.group TASK_GROUP_NAME
dependsOn prepareTask
group TASK_GROUP_NAME
// TODO get rid of this and try to adjust the CopySpec for the gems
// to exclude '.jrubydir'
// there are other duplicates as well :(
setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
customConfigName = "jrubyJarEmbeds-${hashCode()}"
project.afterEvaluate {
addJRubyDependency()
applyConfig()
}
}
/**
* Adds our jruby-complete to a custom configuration only so it can be
* safely unzipped later when we build the jar
@ -304,10 +311,10 @@ class JRubyJar extends Jar {
/** Update the staging directory and tasks responsible for setting it up */
void updateStageDirectory() {
File dir = project.file("${project.buildDir}/dirinfo/${configuration}")
File dir = projectOperations.file("${project.buildDir}/dirinfo/${configuration}")
prepareTask.dependencies project.configurations.maybeCreate(configuration)
prepareTask.outputDir dir
prepareTask.outputDir(dir)
logger.info("${this} including files in ${dir}")
from(dir) {
@ -315,6 +322,30 @@ class JRubyJar extends Jar {
}
}
@Internal
protected Object scriptName
@Internal
protected JRubyPrepare prepareTask
@Internal
protected String customConfigName
@Internal
protected String embeddedJRubyVersion
@Internal
protected String embeddedJRubyMainsVersion = DEFAULT_JRUBY_MAINS
@Internal
protected String jarConfiguration = DEFAULT_JRUBYJAR_CONFIG
@Internal
protected String jarMainClass
@Internal
protected final ProjectOperations projectOperations
/**
* Provide a custom {@link CopyAction} to insert .jrubydir files into the archive.
*
@ -325,17 +356,18 @@ class JRubyJar extends Jar {
*/
@Override
protected CopyAction createCopyAction() {
return new JRubyJarCopyAction(getArchivePath(),
getInternalCompressor(),
null, /* DocumentationRegistry */
'utf-8', /* encoding */
[new JRubyDirInfoTransformer()], /* transformers */
[], /* relocators */
mainSpec.buildRootResolver().getPatternSet(), /* patternSet */
false, /* preserveFileTimestamps */
false, /* minimizeJar */
null /* unusedTracker */
)
new JRubyJarCopyAction(
getArchiveProviderSafely(),
getInternalCompressor(),
null, /* DocumentationRegistry */
'utf-8', /* encoding */
[new JRubyDirInfoTransformer()], /* transformers */
[], /* relocators */
mainSpec.buildRootResolver().getPatternSet(), /* patternSet */
false, /* preserveFileTimestamps */
false, /* minimizeJar */
null /* unusedTracker */
)
}
@ -363,11 +395,22 @@ class JRubyJar extends Jar {
return baseName.replaceAll('(?i)jruby', 'JRuby').capitalize()
}
protected Object scriptName
protected JRubyPrepare prepareTask
protected String customConfigName
protected String embeddedJRubyVersion
protected String embeddedJRubyMainsVersion = DEFAULT_JRUBY_MAINS
protected String jarConfiguration = DEFAULT_JRUBYJAR_CONFIG
protected String jarMainClass
@CompileDynamic
private Provider<File> getArchiveProviderSafely() {
if (LegacyLevel.PRE_5_1) {
projectOperations.provider { -> archivePath }
} else {
archiveFile.map { RegularFile it -> it.asFile }
}
}
@CompileDynamic
@SuppressWarnings('DuplicateStringLiteral')
private void addJrubyAppendix() {
if (LegacyLevel.PRE_5_1) {
appendix = 'jruby'
} else {
archiveAppendix.set('jruby')
}
}
}

View File

@ -24,6 +24,7 @@
package com.github.jrubygradle.jar.internal
import com.github.jengelman.gradle.plugins.shadow.impl.RelocatorRemapper
import com.github.jengelman.gradle.plugins.shadow.internal.UnusedTracker
/*
* This source code is derived from Apache 2.0 licensed software copyright John
@ -31,7 +32,6 @@ import com.github.jengelman.gradle.plugins.shadow.impl.RelocatorRemapper
* repository: https://github.com/johnrengelman/shadow
*/
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
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
@ -50,6 +50,7 @@ import org.gradle.api.internal.file.DefaultFileTreeElement
import org.gradle.api.internal.file.copy.CopyAction
import org.gradle.api.internal.file.copy.CopyActionProcessingStream
import org.gradle.api.internal.file.copy.FileCopyDetailsInternal
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.WorkResult
import org.gradle.api.tasks.WorkResults
import org.gradle.api.tasks.bundling.Zip
@ -86,7 +87,7 @@ import java.util.zip.ZipException
class JRubyJarCopyAction implements CopyAction {
static final long CONSTANT_TIME_FOR_ZIP_ENTRIES = (new GregorianCalendar(1980, 1, 1, 0, 0, 0)).timeInMillis
private final File zipFile
private final Provider<File> zipFile
private final ZipCompressor compressor
private final DocumentationRegistry documentationRegistry
private final List<Transformer> transformers
@ -97,7 +98,7 @@ class JRubyJarCopyAction implements CopyAction {
private final boolean minimizeJar
private final UnusedTracker unusedTracker
JRubyJarCopyAction(File zipFile, ZipCompressor compressor, DocumentationRegistry documentationRegistry,
JRubyJarCopyAction(Provider<File> zipFile, ZipCompressor compressor, DocumentationRegistry documentationRegistry,
String encoding, List<Transformer> transformers, List<Relocator> relocators,
PatternSet patternSet,
boolean preserveFileTimestamps, boolean minimizeJar, UnusedTracker unusedTracker) {
@ -133,8 +134,9 @@ class JRubyJarCopyAction implements CopyAction {
unusedClasses = Collections.emptySet()
}
File zipFileResolved = zipFile.get()
try {
final ZipOutputStream zipOutStr = compressor.createArchiveOutputStream(zipFile)
final ZipOutputStream zipOutStr = compressor.createArchiveOutputStream(zipFileResolved)
withResource(zipOutStr, new Action<ZipOutputStream>() {
void execute(ZipOutputStream outputStream) {
try {
@ -156,7 +158,7 @@ class JRubyJarCopyAction implements CopyAction {
)
}
} catch (Exception e) {
throw new GradleException("Could not create ZIP '${zipFile.toString()}'", e)
throw new GradleException("Could not create ZIP '${zipFileResolved}'", e)
}
return WorkResults.didWork(true)
}
@ -273,7 +275,7 @@ class JRubyJarCopyAction implements CopyAction {
}
recordVisit(fileDetails.relativePath)
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e)
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile.get()), e)
}
}
@ -357,7 +359,7 @@ class JRubyJarCopyAction implements CopyAction {
zipOutStr.closeEntry()
recordVisit(dirDetails.relativePath)
} catch (Exception e) {
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e)
throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile.get()), e)
}
}