Skip to content

Commit b308fd2

Browse files
authored
Merge pull request #399 from ysb33r/master
If the plugin version changes, resolve all dependencies again (#398)
2 parents 7fe59b4 + d57e2f4 commit b308fd2

File tree

8 files changed

+124
-9
lines changed

8 files changed

+124
-9
lines changed

base-plugin/src/main/groovy/com/github/jrubygradle/JRubyPrepare.groovy

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ package com.github.jrubygradle
2626
import com.github.jrubygradle.api.core.AbstractJRubyPrepare
2727
import com.github.jrubygradle.internal.JRubyExecUtils
2828
import groovy.transform.CompileStatic
29+
import org.gradle.api.provider.Provider
30+
31+
import java.util.concurrent.Callable
2932

3033
/** Task for preparing a project-local installation of GEMs & JARs.
3134
*
@@ -46,8 +49,21 @@ class JRubyPrepare extends AbstractJRubyPrepare {
4649
* @return Path on local filesystem
4750
*/
4851
@Override
49-
protected File getJrubyJarLocation() {
50-
JRubyExecUtils.jrubyJar(this.jruby.jrubyConfiguration)
52+
protected Provider<File> getJrubyJarLocation() {
53+
project.provider({ JRubyPluginExtension jrubyExt ->
54+
JRubyExecUtils.jrubyJar(jrubyExt.jrubyConfiguration)
55+
}.curry(this.jruby) as Callable<File>)
56+
}
57+
58+
/** Version of JRuby to be used.
59+
*
60+
* This method should not resolve any files to obtain the version.
61+
*
62+
* @return Intended version of JRuby.
63+
*/
64+
@Override
65+
protected String getJrubyVersion() {
66+
jruby.jrubyVersion
5167
}
5268

5369
private final JRubyPluginExtension jruby

core-plugin/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ bintray {
3939
}
4040
}
4141
}
42+
43+
44+
processResources {
45+
filesMatching '**/com.jrubygradle.core-plugin.version.properties', {
46+
expand VERSION : project.version
47+
}
48+
}
49+
4250
bintrayUpload.dependsOn assemble

core-plugin/src/main/groovy/com/github/jrubygradle/api/core/AbstractJRubyPrepare.groovy

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ import groovy.transform.CompileStatic
2929
import org.gradle.api.DefaultTask
3030
import org.gradle.api.artifacts.Configuration
3131
import org.gradle.api.file.FileCollection
32+
import org.gradle.api.provider.Provider
33+
import org.gradle.api.tasks.Input
3234
import org.gradle.api.tasks.InputFiles
3335
import org.gradle.api.tasks.Internal
3436
import org.gradle.api.tasks.Optional
35-
import org.gradle.api.tasks.OutputFile
3637
import org.gradle.api.tasks.TaskAction
3738

3839
import static com.github.jrubygradle.api.gems.GemOverwriteAction.SKIP
@@ -102,13 +103,22 @@ abstract class AbstractJRubyPrepare extends DefaultTask implements JRubyAwareTas
102103
*
103104
* @return Path on local filesystem
104105
*/
105-
@OutputFile
106-
abstract protected File getJrubyJarLocation()
106+
@Internal
107+
abstract protected Provider<File> getJrubyJarLocation()
108+
109+
/** Version of JRuby to be used.
110+
*
111+
* This method should not resolve any files to obtain the version.
112+
*
113+
* @return Intended version of JRuby.
114+
*/
115+
@Input
116+
abstract protected String getJrubyVersion()
107117

108118
@TaskAction
109119
void exec() {
110120
File out = getOutputDir()
111-
File jrubyJar = jrubyJarLocation
121+
File jrubyJar = jrubyJarLocation.get()
112122
extractGems(project, jrubyJar, gemsAsFileCollection(), out, SKIP)
113123

114124
dependencies.findAll {

core-plugin/src/main/groovy/com/github/jrubygradle/internal/core/IvyXmlGlobalProxyRegistry.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class IvyXmlGlobalProxyRegistry {
4444
* @param project Associated project.
4545
*/
4646
IvyXmlGlobalProxyRegistry(Project project) {
47-
rootCacheDir = new File(project.gradle.gradleUserHomeDir, 'rubygems-ivyxml-cache')
47+
rootCacheDir = new File(project.gradle.gradleUserHomeDir, "rubygems-ivyxml-cache/${PluginMetadata.version()}")
4848
refresh = project.gradle.startParameter.refreshDependencies
4949
}
5050

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2014-2019, R. Tyler Croy <[email protected]>,
3+
* Schalk Cronje <[email protected]>, Christian Meier, Lookout, Inc.
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining
6+
* a copy of this software and associated documentation files (the
7+
* "Software"), to deal in the Software without restriction, including
8+
* without limitation the rights to use, copy, modify, merge, publish,
9+
* distribute, sublicense, and/or sell copies of the Software, and to
10+
* permit persons to whom the Software is furnished to do so, subject to
11+
* the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be
14+
* included in all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*/
24+
package com.github.jrubygradle.internal.core
25+
26+
import groovy.transform.CompileStatic
27+
28+
/** Provides some metadata about this plugin
29+
*
30+
* @author Schalk W. Cronjé
31+
*
32+
* @since 2.0.0
33+
*
34+
*/
35+
@CompileStatic
36+
class PluginMetadata {
37+
38+
/** Plugin version
39+
*
40+
* @return Version of this plugin.
41+
*/
42+
static String version() {
43+
METADATA['version']
44+
}
45+
46+
private static Map<String,String> loadProperties() {
47+
final String location = 'META-INF/jruby-gradle/com.jrubygradle.core-plugin.version.properties'
48+
final Properties props = new Properties()
49+
PluginMetadata.classLoader.getResourceAsStream(location).withCloseable { strm ->
50+
props.load(strm)
51+
}
52+
props as Map<String,String>
53+
}
54+
55+
private static final Map<String,String> METADATA = loadProperties()
56+
}

core-plugin/src/main/groovy/com/github/jrubygradle/internal/gems/GemToIvy.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class GemToIvy {
147147
writer.toString()
148148
}
149149

150-
/** Writes the SHA1 checksum of the {@code ivy.xmnl} file.
150+
/** Writes the SHA1 checksum of the {@code ivy.xml} file.
151151
*
152152
* @param ivyXml Fle containing the {@code ivy.xml} content/
153153
* @return Checksum file.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Copyright (c) 2014-2019, R. Tyler Croy <[email protected]>,
3+
# Schalk Cronje <[email protected]>, Christian Meier, Lookout, Inc.
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining
6+
# a copy of this software and associated documentation files (the
7+
# "Software"), to deal in the Software without restriction, including
8+
# without limitation the rights to use, copy, modify, merge, publish,
9+
# distribute, sublicense, and/or sell copies of the Software, and to
10+
# permit persons to whom the Software is furnished to do so, subject to
11+
# the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be
14+
# included in all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
#
24+
25+
version=${VERSION}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=2.0.0-alpha.4
1+
version=2.0.0-alpha.5
22
group=com.github.jruby-gradle
33
copyrightYear=2014-2019
44

0 commit comments

Comments
 (0)