Compare commits

...

3 Commits

Author SHA1 Message Date
Schalk Cronje 7e130116f1 Proposed JRuby version can be optional 2019-12-24 16:14:31 +01:00
Schalk W. Cronjé b308fd2b0d
Merge pull request #399 from ysb33r/master
If the plugin version changes, resolve all dependencies again (#398)
2019-12-24 15:36:50 +01:00
Schalk Cronje d57e2f42de If the plugin version changes, resolve all dependencies again (#398) 2019-12-24 15:19:44 +01:00
11 changed files with 131 additions and 14 deletions

View File

@ -184,12 +184,12 @@ class JRubyExec extends JavaExec implements JRubyAwareTask, JRubyExecSpec {
/** If it is required that a JRubyExec task needs to be executed with a different version of JRuby that the
* globally configured one, it can be done by setting it here.
*
* @deprecated Use{@code jruby.getJrubyVersion( )} instead.
* @deprecated Use{@code jruby.getProposedJRubyVersion( )} instead.
*
*/
@Deprecated
String getJrubyVersion() {
deprecated('Use jruby.getJrubyVersion() rather getJrubyVersion()')
deprecated('Use jruby.getProposedJRubyVersion() rather getProposedJRubyVersion()')
jruby.jrubyVersion
}

View File

@ -111,7 +111,7 @@ class JRubyPluginExtension extends AbstractCombinedProjectTaskExtension {
*/
@Deprecated
String getDefaultVersion() {
deprecated('Use getJrubyVersion() rather than getDefaultVersion()')
deprecated('Use getProposedJRubyVersion() rather than getDefaultVersion()')
getJrubyVersion()
}

View File

@ -26,6 +26,9 @@ package com.github.jrubygradle
import com.github.jrubygradle.api.core.AbstractJRubyPrepare
import com.github.jrubygradle.internal.JRubyExecUtils
import groovy.transform.CompileStatic
import org.gradle.api.provider.Provider
import java.util.concurrent.Callable
/** Task for preparing a project-local installation of GEMs & JARs.
*
@ -46,8 +49,21 @@ class JRubyPrepare extends AbstractJRubyPrepare {
* @return Path on local filesystem
*/
@Override
protected File getJrubyJarLocation() {
JRubyExecUtils.jrubyJar(this.jruby.jrubyConfiguration)
protected Provider<File> getJrubyJarLocation() {
project.provider({ JRubyPluginExtension jrubyExt ->
JRubyExecUtils.jrubyJar(jrubyExt.jrubyConfiguration)
}.curry(this.jruby) as Callable<File>)
}
/** Version of JRuby to be used.
*
* This method should not resolve any files to obtain the version.
*
* @return Intended version of JRuby.
*/
@Override
protected String getProposedJRubyVersion() {
jruby.jrubyVersion
}
private final JRubyPluginExtension jruby

View File

@ -72,12 +72,12 @@ class JRubyExecTaskSpec extends Specification {
when:
project.configure(execTask) {
jruby.gemConfiguration configurationName
jruby.jrubyVersion newVersion
jruby.getProposedJRubyVersion newVersion
}
project.evaluate()
then:
execTask.jruby.jrubyVersion != project.jruby.jrubyVersion
execTask.jruby.jrubyVersion != project.jruby.getProposedJRubyVersion
and: "jrubyConfigurationName must point to this new configuration"
execTask.jruby.getGemConfiguration().name == configurationName

View File

@ -39,4 +39,12 @@ bintray {
}
}
}
processResources {
filesMatching '**/com.jrubygradle.core-plugin.version.properties', {
expand VERSION : project.version
}
}
bintrayUpload.dependsOn assemble

View File

@ -29,10 +29,11 @@ import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.FileCollection
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import static com.github.jrubygradle.api.gems.GemOverwriteAction.SKIP
@ -102,13 +103,24 @@ abstract class AbstractJRubyPrepare extends DefaultTask implements JRubyAwareTas
*
* @return Path on local filesystem
*/
@OutputFile
abstract protected File getJrubyJarLocation()
@Internal
abstract protected Provider<File> getJrubyJarLocation()
/** Version of JRuby to be used.
*
* This method should not resolve any files to obtain the version.
*
* @return Intended version of JRuby. Can be {@code null} if the version
* is indirectly inferred via configuration.
*/
@Input
@Optional
abstract protected String getProposedJRubyVersion()
@TaskAction
void exec() {
File out = getOutputDir()
File jrubyJar = jrubyJarLocation
File jrubyJar = jrubyJarLocation.get()
extractGems(project, jrubyJar, gemsAsFileCollection(), out, SKIP)
dependencies.findAll {

View File

@ -44,7 +44,7 @@ class IvyXmlGlobalProxyRegistry {
* @param project Associated project.
*/
IvyXmlGlobalProxyRegistry(Project project) {
rootCacheDir = new File(project.gradle.gradleUserHomeDir, 'rubygems-ivyxml-cache')
rootCacheDir = new File(project.gradle.gradleUserHomeDir, "rubygems-ivyxml-cache/${PluginMetadata.version()}")
refresh = project.gradle.startParameter.refreshDependencies
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2014-2019, R. Tyler Croy <rtyler@brokenco.de>,
* Schalk Cronje <ysb33r@gmail.com>, Christian Meier, Lookout, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.github.jrubygradle.internal.core
import groovy.transform.CompileStatic
/** Provides some metadata about this plugin
*
* @author Schalk W. Cronjé
*
* @since 2.0.0
*
*/
@CompileStatic
class PluginMetadata {
/** Plugin version
*
* @return Version of this plugin.
*/
static String version() {
METADATA['version']
}
private static Map<String,String> loadProperties() {
final String location = 'META-INF/jruby-gradle/com.jrubygradle.core-plugin.version.properties'
final Properties props = new Properties()
PluginMetadata.classLoader.getResourceAsStream(location).withCloseable { strm ->
props.load(strm)
}
props as Map<String,String>
}
private static final Map<String,String> METADATA = loadProperties()
}

View File

@ -147,7 +147,7 @@ class GemToIvy {
writer.toString()
}
/** Writes the SHA1 checksum of the {@code ivy.xmnl} file.
/** Writes the SHA1 checksum of the {@code ivy.xml} file.
*
* @param ivyXml Fle containing the {@code ivy.xml} content/
* @return Checksum file.

View File

@ -0,0 +1,25 @@
#
# Copyright (c) 2014-2019, R. Tyler Croy <rtyler@brokenco.de>,
# Schalk Cronje <ysb33r@gmail.com>, Christian Meier, Lookout, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
version=${VERSION}

View File

@ -1,4 +1,4 @@
version=2.0.0-alpha.4
version=2.0.0-alpha.6
group=com.github.jruby-gradle
copyrightYear=2014-2019