Skip to content

Commit c737ee0

Browse files
authored
Merge pull request #419 from lptr/lptr/fix-validation-warnings-2.0
Fix task property annotation problems for 2.0
2 parents 553702e + e07ddf8 commit c737ee0

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import org.gradle.api.GradleException
3232
import org.gradle.api.file.FileCopyDetails
3333
import org.gradle.api.file.RelativePath
3434
import org.gradle.api.tasks.Input
35+
import org.gradle.api.tasks.Internal
3536
import org.gradle.api.tasks.OutputFile
3637
import org.gradle.api.tasks.TaskAction
3738
import org.ysb33r.grolifant.api.StringUtils
@@ -71,6 +72,7 @@ class GenerateGradleRb extends DefaultTask implements JRubyAwareTask {
7172
this.gemInstallDir = dir
7273
}
7374

75+
@Internal
7476
File getDestinationDir() {
7577
project.file(destinationDir)
7678
}
@@ -85,18 +87,24 @@ class GenerateGradleRb extends DefaultTask implements JRubyAwareTask {
8587
StringUtils.stringize(baseName)
8688
}
8789

90+
@Internal
8891
File getGemInstallDir() {
8992
project.file(this.gemInstallDir)
9093
}
9194

95+
@Input
96+
protected String getGemInstallDirPath() {
97+
getGemInstallDir().absolutePath
98+
}
99+
92100
@TaskAction
93101
@CompileDynamic
94102
@SuppressWarnings('DuplicateStringLiteral')
95103
void generate() {
96104
Object source = getSourceFromResource()
97105
File destination = destinationFile().parentFile
98106
String path = classpathFromConfiguration(jruby.jrubyConfiguration).join(File.pathSeparator)
99-
String gemDir = getGemInstallDir().absolutePath
107+
String gemDir = getGemInstallDirPath()
100108
String bootstrapName = getBaseName()
101109
logger.info("GenerateGradleRb - source: ${source}, destination: ${destination}, baseName: ${baseName}")
102110
project.copy {

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ import com.github.jrubygradle.internal.JRubyExecUtils
2929
import groovy.transform.CompileStatic
3030
import org.gradle.api.Task
3131
import org.gradle.api.artifacts.Configuration
32+
import org.gradle.api.model.ReplacedBy
3233
import org.gradle.api.provider.Provider
3334
import org.gradle.api.tasks.Input
35+
import org.gradle.api.tasks.Internal
3436
import org.gradle.api.tasks.JavaExec
37+
import org.gradle.api.tasks.LocalState
3538
import org.gradle.api.tasks.Optional
3639
import org.gradle.process.JavaExecSpec
3740
import org.gradle.util.GradleVersion
@@ -89,8 +92,7 @@ class JRubyExec extends JavaExec implements JRubyAwareTask, JRubyExecSpec {
8992
/** Script to execute.
9093
* @return The path to the script (or {@code null} if not set)
9194
*/
92-
@Optional
93-
@Input
95+
@Internal
9496
File getScript() {
9597
resolveScript(project, this.script)
9698
}
@@ -175,6 +177,7 @@ class JRubyExec extends JavaExec implements JRubyAwareTask, JRubyExecSpec {
175177
*
176178
* @return Provider of GEM working directory.
177179
*/
180+
@LocalState
178181
Provider<File> getGemWorkDir() {
179182
Callable<File> resolveGemWorkDir = { JRubyPluginExtension jpe ->
180183
((JRubyPrepare) project.tasks.getByName(jpe.gemPrepareTaskName)).outputDir
@@ -190,6 +193,7 @@ class JRubyExec extends JavaExec implements JRubyAwareTask, JRubyExecSpec {
190193
*
191194
*/
192195
@Deprecated
196+
@ReplacedBy('jruby.jrubyVersion')
193197
String getJrubyVersion() {
194198
deprecated('Use jruby.getJrubyVersion() rather getJrubyVersion()')
195199
jruby.jrubyVersion
@@ -306,6 +310,15 @@ class JRubyExec extends JavaExec implements JRubyAwareTask, JRubyExecSpec {
306310
throw notAllowed(USE_JVM_ARGS)
307311
}
308312

313+
/** Capture the path of the script as an input.
314+
* @return the path of the script to execute.
315+
*/
316+
@Optional
317+
@Input
318+
protected String getScriptPath() {
319+
getScript()?.path
320+
}
321+
309322
private static UnsupportedOperationException notAllowed(final String msg) {
310323
return new UnsupportedOperationException(msg)
311324
}

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ subprojects {
107107
ideReport.enabled = true
108108
ideReport.destination = file( "${project.codenarc.reportsDir}/${reportName}.ide.txt")
109109
}
110+
111+
tasks.withType(ValidateTaskProperties) { validateTaskProperties ->
112+
validateTaskProperties.failOnWarning = true
113+
validateTaskProperties.enableStricterValidation = true
114+
}
110115
}
111116

112117
idea {

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ import org.gradle.api.tasks.Input
3434
import org.gradle.api.tasks.InputFiles
3535
import org.gradle.api.tasks.Internal
3636
import org.gradle.api.tasks.Optional
37+
import org.gradle.api.tasks.PathSensitive
3738
import org.gradle.api.tasks.TaskAction
3839

3940
import static com.github.jrubygradle.api.gems.GemOverwriteAction.SKIP
4041
import static com.github.jrubygradle.api.gems.GemUtils.extractGems
4142
import static com.github.jrubygradle.api.gems.GemUtils.setupJars
43+
import static org.gradle.api.tasks.PathSensitivity.ABSOLUTE
4244

4345
/** Abstract base class for building custom tasks for preparing GEMs.
4446
*
@@ -81,9 +83,24 @@ abstract class AbstractJRubyPrepare extends DefaultTask implements JRubyAwareTas
8183
/** All GEMs that have been supplied as dependencies.
8284
*
8385
* @return Collection of GEMs.
86+
*
87+
* @see #getGemsAsFileCollection()
88+
* @deprecated Use {@link #getGemsAsFileCollection()} instead.
8489
*/
85-
@InputFiles
90+
@Deprecated
8691
FileCollection gemsAsFileCollection() {
92+
gemsAsFileCollection
93+
}
94+
95+
/** All GEMs that have been supplied as dependencies.
96+
*
97+
* @return Collection of GEMs.
98+
*
99+
* @since 2.1.0
100+
*/
101+
@InputFiles
102+
@PathSensitive(ABSOLUTE)
103+
FileCollection getGemsAsFileCollection() {
87104
return GemUtils.getGems(project.files(this.dependencies))
88105
}
89106

@@ -94,7 +111,6 @@ abstract class AbstractJRubyPrepare extends DefaultTask implements JRubyAwareTas
94111
*
95112
* @param f One or more of file, directory, configuration or list of gems.
96113
*/
97-
@Optional
98114
void dependencies(Object... f) {
99115
this.dependencies.addAll(f.toList())
100116
}
@@ -121,7 +137,7 @@ abstract class AbstractJRubyPrepare extends DefaultTask implements JRubyAwareTas
121137
void exec() {
122138
File out = getOutputDir()
123139
File jrubyJar = jrubyJarLocation.get()
124-
extractGems(project, jrubyJar, gemsAsFileCollection(), out, SKIP)
140+
extractGems(project, jrubyJar, gemsAsFileCollection, out, SKIP)
125141

126142
dependencies.findAll {
127143
it instanceof Configuration

0 commit comments

Comments
 (0)