Cleanup Codenarc violations (#351)
This commit is contained in:
parent
79a2f52666
commit
7557fe46ee
|
@ -2,7 +2,6 @@ package com.github.jrubygradle
|
|||
|
||||
import com.github.jrubygradle.testhelper.IntegrationSpecification
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import spock.lang.Shared
|
||||
|
||||
/**
|
||||
* @author Schalk W. Cronjé
|
||||
|
@ -19,7 +18,6 @@ class JRubyExecExtensionIntegrationSpec extends IntegrationSpecification {
|
|||
script 'src/${HELLO_WORLD}'
|
||||
"""
|
||||
|
||||
|
||||
when: "I call jrubyexec with only a script name"
|
||||
BuildResult result = build()
|
||||
|
||||
|
@ -136,10 +134,12 @@ class JRubyExecExtensionIntegrationSpec extends IntegrationSpecification {
|
|||
gradleRunner(DEFAULT_TASK_NAME, '-i').build()
|
||||
}
|
||||
|
||||
@SuppressWarnings('BuilderMethodWithSideEffects')
|
||||
private void createJRubyExecProject(String jrubyexecConfig) {
|
||||
createJRubyExecProject('', jrubyexecConfig)
|
||||
}
|
||||
|
||||
@SuppressWarnings('BuilderMethodWithSideEffects')
|
||||
private void createJRubyExecProject(String preamble, String jrubyexecConfig) {
|
||||
buildFile.text = """
|
||||
${projectWithLocalRepo}
|
||||
|
@ -157,7 +157,7 @@ class JRubyExecExtensionIntegrationSpec extends IntegrationSpecification {
|
|||
}
|
||||
|
||||
private String withJarToUse(String jarFormat) {
|
||||
String dependencies = """
|
||||
"""
|
||||
dependencies {
|
||||
jrubyExec ${jarFormat}
|
||||
}
|
||||
|
@ -171,6 +171,4 @@ class JRubyExecExtensionIntegrationSpec extends IntegrationSpecification {
|
|||
private String getBcprovVer() {
|
||||
testProperties.bcprovVersion
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,13 +34,13 @@ class JRubyGenerateGradleRbIntegrationSpec extends IntegrationSpecification {
|
|||
String content = expected.text
|
||||
|
||||
then: "The GEM_HOME to include gemInstallDir"
|
||||
expected.text.contains "export GEM_HOME=\"${new File(projectDir, 'build/gems').absolutePath}"
|
||||
content.contains "export GEM_HOME=\"${new File(projectDir, 'build/gems').absolutePath}"
|
||||
|
||||
and: "The JARS_HOME is set"
|
||||
expected.text.contains('export JARS_HOME=')
|
||||
content.contains('export JARS_HOME=')
|
||||
|
||||
and: "The java command invoked with the -cp flag"
|
||||
// with this test setup it is just jrubyExec.asPath
|
||||
expected.text.contains "-cp ${flatRepoLocation.absolutePath}"
|
||||
content.contains "-cp ${flatRepoLocation.absolutePath}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.github.jrubygradle
|
||||
|
||||
import com.github.jrubygradle.testhelper.BasicProjectBuilder
|
||||
import com.github.jrubygradle.testhelper.IntegrationSpecification
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package com.github.jrubygradle.testhelper
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
|
||||
import static org.gradle.api.logging.LogLevel.LIFECYCLE
|
||||
|
||||
/**
|
||||
* @author Schalk W. Cronjé.
|
||||
*/
|
||||
class BasicProjectBuilder {
|
||||
|
||||
static Project buildWithStdRepo( final File projectDir_, final File cacheDir_ ) {
|
||||
Project project = ProjectBuilder.builder().withProjectDir(projectDir_).build()
|
||||
File repo = project.file("../../../../../../src/integTest/mavenrepo")
|
||||
if (!repo.exists()){
|
||||
throw new RuntimeException("no repo at " + repo)
|
||||
}
|
||||
project.with {
|
||||
apply plugin: 'com.github.jruby-gradle.base'
|
||||
jruby.defaultRepositories = true
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + repo.absolutePath
|
||||
}
|
||||
}
|
||||
}
|
||||
project
|
||||
}
|
||||
|
||||
static Project buildWithLocalRepo( final File projectDir_, final File repoDir_, final File cacheDir_ ) {
|
||||
Project project = ProjectBuilder.builder().withProjectDir(projectDir_).build()
|
||||
project.with {
|
||||
apply plugin: 'com.github.jruby-gradle.base'
|
||||
|
||||
jruby.defaultRepositories = false
|
||||
|
||||
repositories {
|
||||
flatDir dirs : repoDir_.absolutePath
|
||||
}
|
||||
|
||||
}
|
||||
project
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import org.junit.rules.TemporaryFolder
|
|||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class IntegrationSpecification extends Specification {
|
||||
|
||||
static final boolean OFFLINE = System.getProperty('TESTS_ARE_OFFLINE')
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package com.github.jrubygradle.testhelper
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
/**
|
||||
* @author Schalk W. Cronjé.
|
||||
*/
|
||||
class VersionFinder {
|
||||
static String find( final File repoDir, final String artifact, final String extension ) {
|
||||
@SuppressWarnings(['NoDef'])
|
||||
static String find(final File repoDir, final String artifact, final String extension) {
|
||||
Pattern pat = ~/^${artifact}-(.+)\.${extension}/
|
||||
def files = repoDir.list([ accept : { File dir,String name ->
|
||||
def files = repoDir.list([ accept: { File dir, String name ->
|
||||
name ==~ pat
|
||||
}] as FilenameFilter)
|
||||
} ] as FilenameFilter)
|
||||
|
||||
if (files.size()) {
|
||||
def matcher = files[0] =~ pat
|
||||
|
@ -22,7 +21,7 @@ class VersionFinder {
|
|||
}
|
||||
}
|
||||
|
||||
static findDependency( final File repoDir, final String organisation, final String artifact, final String extension ) {
|
||||
"${organisation}:${artifact}:${find(repoDir,artifact,extension)}@${extension}"
|
||||
static String findDependency(final File repoDir, final String organisation, final String artifact, final String extension) {
|
||||
"${organisation}:${artifact}:${find(repoDir, artifact, extension)}@${extension}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.github.jrubygradle
|
||||
|
||||
import com.github.jrubygradle.internal.JRubyExecDelegate
|
||||
import com.github.jrubygradle.internal.GemVersionResolver
|
||||
import com.github.jrubygradle.internal.JRubyExecDelegate
|
||||
import com.github.jrubygradle.internal.JRubyExecUtils
|
||||
import com.github.jrubygradle.internal.RubygemsServlet
|
||||
import org.gradle.api.Plugin
|
||||
|
@ -65,7 +65,7 @@ class JRubyPlugin implements Plugin<Project> {
|
|||
// can not cast
|
||||
Object embedded = embeddedServer()
|
||||
String path = embedded.addRepository(localUrl)
|
||||
project.logger.info( 'Adding remote rubygems repo: {}', localUrl)
|
||||
project.logger.info('Adding remote rubygems repo: {}', localUrl)
|
||||
maven {
|
||||
url {
|
||||
startEmbeddedServer(project)
|
||||
|
@ -87,6 +87,7 @@ class JRubyPlugin implements Plugin<Project> {
|
|||
|
||||
// can not cast same object from different classloaders
|
||||
private Object server
|
||||
|
||||
private Object embeddedServer() {
|
||||
if (server == null) {
|
||||
// TODO maybe things will work now without cloning
|
||||
|
@ -97,7 +98,7 @@ class JRubyPlugin implements Plugin<Project> {
|
|||
List<URL> urls = [] as Queue
|
||||
URL warFileURL
|
||||
RubygemsServlet.classLoader.URLs.each {
|
||||
if (it.file.endsWith('.war') ) {
|
||||
if (it.file.endsWith('.war')) {
|
||||
warFileURL = it
|
||||
}
|
||||
// for integTest we need to filter some jars here
|
||||
|
@ -115,6 +116,7 @@ class JRubyPlugin implements Plugin<Project> {
|
|||
}
|
||||
|
||||
private boolean serverStarted = false
|
||||
|
||||
private void startEmbeddedServer(Project project) {
|
||||
if (server != null && !serverStarted) {
|
||||
// we need to set the current thread context class loader
|
||||
|
|
|
@ -57,8 +57,7 @@ class JRubyExecUtils {
|
|||
* @param jar JRuby Jar
|
||||
* @return Version string map [major,minor,patchlevel] or null
|
||||
*
|
||||
* @since 0.1.16
|
||||
* @deprecated This method is no longer used and will be removed in a later
|
||||
* @since 0.1.16* @deprecated This method is no longer used and will be removed in a later
|
||||
* version
|
||||
*/
|
||||
@CompileDynamic
|
||||
|
@ -76,9 +75,9 @@ class JRubyExecUtils {
|
|||
}
|
||||
|
||||
return [
|
||||
major : matches[0][1].toInteger(),
|
||||
minor : matches[0][2].toInteger(),
|
||||
patchlevel : matches[0][3].toInteger()
|
||||
major : matches[0][1].toInteger(),
|
||||
minor : matches[0][2].toInteger(),
|
||||
patchlevel: matches[0][3].toInteger()
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -105,9 +104,9 @@ class JRubyExecUtils {
|
|||
* @return sequential list of arguments to pass jruby-complete.jar
|
||||
*/
|
||||
static List<String> buildArgs(List<Object> extra,
|
||||
List<Object> jrubyArgs,
|
||||
File script,
|
||||
List<Object> scriptArgs) {
|
||||
List<Object> jrubyArgs,
|
||||
File script,
|
||||
List<Object> scriptArgs) {
|
||||
List<Object> cmdArgs = extra
|
||||
// load Jars.lock on startup
|
||||
cmdArgs.add('-rjars/setup')
|
||||
|
@ -129,8 +128,7 @@ class JRubyExecUtils {
|
|||
throw new InvalidUserDataException("${script} does not exist")
|
||||
}
|
||||
cmdArgs.add(script.toString())
|
||||
}
|
||||
else if (script == null) {
|
||||
} else if (script == null) {
|
||||
if (useBinPath && (jrubyArgs.size() <= 1)) {
|
||||
throw new InvalidUserDataException('No `script` property defined and no inline script provided')
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.gradle.api.file.DuplicateFileCopyingException
|
|||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
/**
|
||||
* @author Schalk W. Cronjé
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.github.jrubygradle
|
||||
|
||||
|
||||
import org.gradle.api.InvalidUserDataException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.ProjectConfigurationException
|
||||
|
@ -67,9 +66,6 @@ class JRubyExecSpec extends Specification {
|
|||
}
|
||||
|
||||
void "Check jruby defaults when jruby.execVersion is changed after the task is created"() {
|
||||
given:
|
||||
final String initialVersion = project.jruby.execVersion
|
||||
|
||||
when: "ExecVersion is changed later on, and JRubyExec.jrubyVersion was not called"
|
||||
project.jruby.execVersion = '1.5.0'
|
||||
|
||||
|
@ -169,10 +165,10 @@ class JRubyExecSpec extends Specification {
|
|||
}
|
||||
|
||||
then:
|
||||
execTask.getArgs() == ['-I', testJarDependencies, '-rjars/setup',
|
||||
'-j1', '-j2', '-j3', '-S',
|
||||
SCRIPT_NAME,
|
||||
'-s1', '-s2', '-s3']
|
||||
execTask.args == ['-I', testJarDependencies, '-rjars/setup',
|
||||
'-j1', '-j2', '-j3', '-S',
|
||||
SCRIPT_NAME,
|
||||
'-s1', '-s2', '-s3']
|
||||
}
|
||||
|
||||
void "Properly handle the lack of a `script` argument"() {
|
||||
|
@ -182,13 +178,12 @@ class JRubyExecSpec extends Specification {
|
|||
}
|
||||
|
||||
then:
|
||||
execTask.getArgs() == ['-I', testJarDependencies, '-rjars/setup', '-S', 'rspec']
|
||||
execTask.args == ['-I', testJarDependencies, '-rjars/setup', '-S', 'rspec']
|
||||
}
|
||||
|
||||
void "Error when `script` is empty and there is no `jrubyArgs`"() {
|
||||
when:
|
||||
project.configure(execTask) {}
|
||||
execTask.getArgs()
|
||||
execTask.args
|
||||
|
||||
then: "An exception should be thrown"
|
||||
thrown(InvalidUserDataException)
|
||||
|
|
|
@ -5,8 +5,7 @@ import org.gradle.api.DefaultTask
|
|||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.*
|
||||
|
||||
import spock.lang.Specification
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -31,9 +30,9 @@ class JRubyExecTraitsSpec extends Specification {
|
|||
void "Filter out RVM environment values by default"() {
|
||||
when:
|
||||
Map preparedEnv = task.getPreparedEnvironment([
|
||||
'GEM_HOME' : '/tmp/spock',
|
||||
'RUBY_VERSION' : 'notaversion',
|
||||
'rvm_ruby_string' : 'jruby-head',
|
||||
'GEM_HOME' : '/tmp/spock',
|
||||
'RUBY_VERSION' : 'notaversion',
|
||||
'rvm_ruby_string': 'jruby-head',
|
||||
])
|
||||
|
||||
then:
|
||||
|
@ -47,12 +46,14 @@ class JRubyExecTraitsSpec extends Specification {
|
|||
|
||||
when:
|
||||
Map preparedEnv = task.getPreparedEnvironment([
|
||||
'GEM_PATH' : '/tmp/spock/invalid',
|
||||
'GEM_PATH': '/tmp/spock/invalid',
|
||||
])
|
||||
|
||||
then:
|
||||
preparedEnv.containsKey('GEM_PATH') }
|
||||
preparedEnv.containsKey('GEM_PATH')
|
||||
}
|
||||
|
||||
@SuppressWarnings('UnnecessaryGetter')
|
||||
void "setting gemWorkDir should work"() {
|
||||
given:
|
||||
String workDir = 'customGemDir'
|
||||
|
@ -67,6 +68,7 @@ class JRubyExecTraitsSpec extends Specification {
|
|||
task.gemWorkDir.absolutePath.endsWith(workDir)
|
||||
}
|
||||
|
||||
@SuppressWarnings('UnnecessaryGetter')
|
||||
void "setting gemWorkDir with traits"() {
|
||||
given:
|
||||
String workDir = 'customGemDir'
|
||||
|
|
|
@ -2,8 +2,7 @@ package com.github.jrubygradle
|
|||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.*
|
||||
|
||||
import spock.lang.Specification
|
||||
|
||||
/**
|
||||
* Unit test covering the JRuby extensions (i.e. project.jruby)
|
||||
|
|
|
@ -30,7 +30,7 @@ class JRubyPluginSpec extends Specification {
|
|||
project.evaluate()
|
||||
|
||||
then: "rubygemsRelease() should be defined"
|
||||
project.repositories.metaClass.respondsTo(project.repositories,'rubygemsRelease')
|
||||
project.repositories.metaClass.respondsTo(project.repositories, 'rubygemsRelease')
|
||||
|
||||
and:
|
||||
hasRepositoryUrl(project, TORQUEBOX_RUBYGEMS_RELEASE_URL)
|
||||
|
|
|
@ -1,93 +1,93 @@
|
|||
package com.github.jrubygradle.internal
|
||||
|
||||
import spock.lang.*
|
||||
|
||||
import org.gradle.api.artifacts.DependencyResolveDetails
|
||||
import org.gradle.api.artifacts.ModuleVersionSelector
|
||||
import spock.lang.Specification
|
||||
|
||||
@SuppressWarnings(['UnnecessaryGetter'])
|
||||
class GemVersionResolverSpec extends Specification {
|
||||
|
||||
void "ignore non rubygems group modules"() {
|
||||
setup:
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details = Mock(DependencyResolveDetails)
|
||||
def requested = Mock(ModuleVersionSelector)
|
||||
details.getRequested() >> requested
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details = Mock(DependencyResolveDetails)
|
||||
def requested = Mock(ModuleVersionSelector)
|
||||
details.getRequested() >> requested
|
||||
|
||||
when:
|
||||
subject.resolve( details )
|
||||
subject.resolve(details)
|
||||
|
||||
then:
|
||||
0 * details.useVersion(_)
|
||||
0 * details.setTarget(_)
|
||||
0 * details.useVersion(_)
|
||||
0 * details.setTarget(_)
|
||||
}
|
||||
|
||||
void "keep rubygems group modules as is on first visit"() {
|
||||
setup:
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details = Mock(DependencyResolveDetails)
|
||||
def requested = Mock(ModuleVersionSelector)
|
||||
details.getRequested() >> requested
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details = Mock(DependencyResolveDetails)
|
||||
def requested = Mock(ModuleVersionSelector)
|
||||
details.getRequested() >> requested
|
||||
|
||||
when:
|
||||
subject.resolve( details )
|
||||
subject.resolve(details)
|
||||
|
||||
then:
|
||||
1 * requested.getGroup() >> 'rubygems'
|
||||
(1.._) * requested.getVersion() >> '1.2.3'
|
||||
0 * details.useVersion(_)
|
||||
0 * details.setTarget(_)
|
||||
subject.toString() != new GemVersionResolver().toString()
|
||||
1 * requested.getGroup() >> 'rubygems'
|
||||
(1.._) * requested.getVersion() >> '1.2.3'
|
||||
0 * details.useVersion(_)
|
||||
0 * details.setTarget(_)
|
||||
subject.toString() != new GemVersionResolver().toString()
|
||||
}
|
||||
|
||||
void "narrows down version range on second visit"() {
|
||||
setup:
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details1 = Mock(DependencyResolveDetails)
|
||||
def requested1 = Mock(ModuleVersionSelector)
|
||||
details1.getRequested() >> requested1
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details1 = Mock(DependencyResolveDetails)
|
||||
def requested1 = Mock(ModuleVersionSelector)
|
||||
details1.getRequested() >> requested1
|
||||
|
||||
def details2 = Mock(DependencyResolveDetails)
|
||||
def requested2 = Mock(ModuleVersionSelector)
|
||||
details2.getRequested() >> requested2
|
||||
def details2 = Mock(DependencyResolveDetails)
|
||||
def requested2 = Mock(ModuleVersionSelector)
|
||||
details2.getRequested() >> requested2
|
||||
|
||||
when:
|
||||
subject.resolve( details1 )
|
||||
subject.resolve( details2 )
|
||||
subject.resolve(details1)
|
||||
subject.resolve(details2)
|
||||
|
||||
then:
|
||||
1 * requested1.getGroup() >> 'rubygems'
|
||||
(1.._) * requested1.getVersion() >> '[1.2.3,3.4.5]'
|
||||
1 * requested2.getGroup() >> 'rubygems'
|
||||
(1.._) * requested2.getVersion() >> '[2.3.4,4.5.6]'
|
||||
0 * details1.useVersion(_)
|
||||
0 * details1.setTarget(_)
|
||||
1 * details2.useVersion('[2.3.4,3.4.5]')
|
||||
0 * details2.setTarget(_)
|
||||
1 * requested1.getGroup() >> 'rubygems'
|
||||
(1.._) * requested1.getVersion() >> '[1.2.3,3.4.5]'
|
||||
1 * requested2.getGroup() >> 'rubygems'
|
||||
(1.._) * requested2.getVersion() >> '[2.3.4,4.5.6]'
|
||||
0 * details1.useVersion(_)
|
||||
0 * details1.setTarget(_)
|
||||
1 * details2.useVersion('[2.3.4,3.4.5]')
|
||||
0 * details2.setTarget(_)
|
||||
}
|
||||
|
||||
void "version conflict"() {
|
||||
setup:
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details1 = Mock(DependencyResolveDetails)
|
||||
def requested1 = Mock(ModuleVersionSelector)
|
||||
details1.getRequested() >> requested1
|
||||
GemVersionResolver subject = new TestGemVersionResolver()
|
||||
def details1 = Mock(DependencyResolveDetails)
|
||||
def requested1 = Mock(ModuleVersionSelector)
|
||||
details1.getRequested() >> requested1
|
||||
|
||||
def details2 = Mock(DependencyResolveDetails)
|
||||
def requested2 = Mock(ModuleVersionSelector)
|
||||
details2.getRequested() >> requested2
|
||||
def details2 = Mock(DependencyResolveDetails)
|
||||
def requested2 = Mock(ModuleVersionSelector)
|
||||
details2.getRequested() >> requested2
|
||||
|
||||
when:
|
||||
subject.resolve( details1 )
|
||||
subject.resolve( details2 )
|
||||
subject.resolve(details1)
|
||||
subject.resolve(details2)
|
||||
|
||||
then:
|
||||
1 * requested1.getGroup() >> 'rubygems'
|
||||
(1.._) * requested1.getVersion() >> '[1.2.3,2.3.4]'
|
||||
1 * requested2.getGroup() >> 'rubygems'
|
||||
(1.._) * requested2.getVersion() >> '[3.4.5,4.5.6]'
|
||||
def exception = thrown(RuntimeException)
|
||||
exception.message == 'there is no overlap for [1.2.3,2.3.4] and [3.4.5,4.5.6]'
|
||||
1 * requested1.getGroup() >> 'rubygems'
|
||||
(1.._) * requested1.getVersion() >> '[1.2.3,2.3.4]'
|
||||
1 * requested2.getGroup() >> 'rubygems'
|
||||
(1.._) * requested2.getVersion() >> '[3.4.5,4.5.6]'
|
||||
def exception = thrown(RuntimeException)
|
||||
exception.message == 'there is no overlap for [1.2.3,2.3.4] and [3.4.5,4.5.6]'
|
||||
}
|
||||
|
||||
static class TestGemVersionResolver extends GemVersionResolver {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.github.jrubygradle.internal
|
||||
|
||||
import spock.lang.*
|
||||
import spock.lang.Specification
|
||||
|
||||
class GemVersionSpec extends Specification {
|
||||
void "parses single version"() {
|
||||
|
|
|
@ -10,12 +10,11 @@ import spock.lang.Specification
|
|||
// Use JRubyExecExtensionIntegrationSpec instead
|
||||
// ===============================================
|
||||
|
||||
|
||||
/**
|
||||
* @author Schalk W. Cronjé
|
||||
*/
|
||||
class JRubyExecDelegateSpec extends Specification {
|
||||
static final String absFilePrefix = System.getProperty('os.name').toLowerCase().startsWith('windows') ? 'C:' : ''
|
||||
static final String ABS_FILE_PREFIX = System.getProperty('os.name').toLowerCase().startsWith('windows') ? 'C:' : ''
|
||||
|
||||
Project project
|
||||
JRubyExecDelegate jred
|
||||
|
@ -55,7 +54,7 @@ class JRubyExecDelegateSpec extends Specification {
|
|||
void "When passing absolute file and absolute file, expect check for existence to be executed"() {
|
||||
given:
|
||||
def cl = {
|
||||
script absFilePrefix + '/path/to/file'
|
||||
script ABS_FILE_PREFIX + '/path/to/file'
|
||||
jrubyArgs 'c', 'd', '-S'
|
||||
scriptArgs '-x'
|
||||
scriptArgs '-y', '-z'
|
||||
|
|
|
@ -2,37 +2,39 @@ package com.github.jrubygradle.internal
|
|||
|
||||
import org.gradle.api.InvalidUserDataException
|
||||
import org.ysb33r.grolifant.api.OperatingSystem
|
||||
import spock.lang.*
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
|
||||
import static com.github.jrubygradle.internal.JRubyExecUtils.buildArgs
|
||||
|
||||
@SuppressWarnings(['BuilderMethodWithSideEffects'])
|
||||
class JRubyExecUtilsSpec extends Specification {
|
||||
static final boolean IS_WINDOWS = OperatingSystem.current().isWindows()
|
||||
|
||||
void "The version string in a jruby jar filename must be extracted correctly"() {
|
||||
|
||||
expect:
|
||||
version == JRubyExecUtils.jrubyJarVersion(new File(jarName))
|
||||
version == JRubyExecUtils.jrubyJarVersion(new File(jarName))
|
||||
|
||||
where:
|
||||
jarName || version
|
||||
'jruby-complete-9.0.0.0.rc2.jar' || '9.0.0.0.rc2'
|
||||
'jruby-complete-9.0.0.0.jar' || '9.0.0.0'
|
||||
'jruby-complete-22.999.888.jar' || '22.999.888'
|
||||
'jruby-complete.jar' || null
|
||||
jarName || version
|
||||
'jruby-complete-9.0.0.0.rc2.jar' || '9.0.0.0.rc2'
|
||||
'jruby-complete-9.0.0.0.jar' || '9.0.0.0'
|
||||
'jruby-complete-22.999.888.jar' || '22.999.888'
|
||||
'jruby-complete.jar' || null
|
||||
}
|
||||
|
||||
void "The version information in a jruby jar filename must be extracted correctly"() {
|
||||
|
||||
expect:
|
||||
triplet == JRubyExecUtils.jrubyJarVersionTriple(new File(jarName))
|
||||
triplet == JRubyExecUtils.jrubyJarVersionTriple(new File(jarName))
|
||||
|
||||
where:
|
||||
jarName || triplet
|
||||
'jruby-complete-9.0.0.0.rc2.jar' || [ major : 9, minor : 0, patchlevel : 0 ]
|
||||
'jruby-complete-9.0.0.0.jar' || [ major : 9, minor : 0, patchlevel : 0 ]
|
||||
'jruby-complete-22.999.888.jar' || [ major : 22, minor : 999, patchlevel : 888 ]
|
||||
'jruby-complete.jar' || [:]
|
||||
jarName || triplet
|
||||
'jruby-complete-9.0.0.0.rc2.jar' || [major: 9, minor: 0, patchlevel: 0]
|
||||
'jruby-complete-9.0.0.0.jar' || [major: 9, minor: 0, patchlevel: 0]
|
||||
'jruby-complete-22.999.888.jar' || [major: 22, minor: 999, patchlevel: 888]
|
||||
'jruby-complete.jar' || [:]
|
||||
}
|
||||
|
||||
void "buildArgs() should raise with no script or jrubyArgs"() {
|
||||
|
|
|
@ -55,7 +55,7 @@ subprojects {
|
|||
|
||||
codenarc {
|
||||
sourceSets = [sourceSets.main]
|
||||
configFile = file("${rootProject.projectDir}/gradle/codenarc.rules")
|
||||
configFile = file("${rootProject.projectDir}/gradle/codenarc.groovy")
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -38,12 +38,13 @@ ruleset {
|
|||
CatchThrowable
|
||||
ChainedTest
|
||||
ClassForName
|
||||
ClassJavadoc
|
||||
ClassJavadoc {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
ClassName
|
||||
ClassNameSameAsFilename
|
||||
ClassNameSameAsSuperclass
|
||||
ClassSize
|
||||
CloneWithoutCloneable
|
||||
CloneableWithoutClone
|
||||
CloseWithoutCloseable
|
||||
ClosureAsLastMethodParameter
|
||||
|
@ -53,8 +54,6 @@ ruleset {
|
|||
ComparisonOfTwoConstants
|
||||
ComparisonWithSelf
|
||||
ConfusingClassNamedException
|
||||
// This warns on all our useful gradle DSL setters
|
||||
//ConfusingMethodName
|
||||
ConfusingMultipleReturns
|
||||
ConfusingTernary
|
||||
ConsecutiveBlankLines
|
||||
|
@ -66,21 +65,23 @@ ruleset {
|
|||
ConstantsOnlyInterface
|
||||
CouldBeElvis
|
||||
CoupledTestCase
|
||||
CrapMetric // Requires the GMetrics jar and a Cobertura coverage file
|
||||
CyclomaticComplexity // Requires the GMetrics jar
|
||||
DeadCode
|
||||
DirectConnectionManagement
|
||||
DoubleCheckedLocking
|
||||
DoubleNegative
|
||||
DuplicateCaseStatement
|
||||
DuplicateImport
|
||||
DuplicateListLiteral
|
||||
DuplicateListLiteral {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
DuplicateMapKey
|
||||
DuplicateMapLiteral
|
||||
// This is silly
|
||||
//DuplicateNumberLiteral
|
||||
DuplicateMapLiteral {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
DuplicateSetValue
|
||||
DuplicateStringLiteral
|
||||
DuplicateStringLiteral {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
ElseBlockBraces
|
||||
EmptyCatchBlock
|
||||
EmptyClass
|
||||
|
@ -124,11 +125,8 @@ ruleset {
|
|||
ExplicitLinkedListInstantiation
|
||||
ExplicitStackInstantiation
|
||||
ExplicitTreeSetInstantiation
|
||||
// using 'build' as a method prefix is okay IMO
|
||||
//FactoryMethodName
|
||||
FieldName
|
||||
FileCreateTempFile
|
||||
FileEndsWithoutNewline
|
||||
FinalClassWithProtectedMember
|
||||
ForLoopShouldBeWhileLoop
|
||||
ForStatementBraces
|
||||
|
@ -140,8 +138,6 @@ ruleset {
|
|||
HardCodedWindowsRootDirectory
|
||||
HashtableIsObsolete
|
||||
IfStatementBraces
|
||||
// Verbose if statements are much more readable IMO
|
||||
//IfStatementCouldBeTernary
|
||||
IllegalClassMember
|
||||
IllegalClassReference
|
||||
IllegalPackageReference
|
||||
|
@ -159,25 +155,9 @@ ruleset {
|
|||
InterfaceName
|
||||
InterfaceNameSameAsSuperInterface
|
||||
InvertedIfElse
|
||||
JUnitAssertAlwaysFails
|
||||
JUnitAssertAlwaysSucceeds
|
||||
JUnitAssertEqualsConstantActualValue
|
||||
JUnitFailWithoutMessage
|
||||
JUnitLostTest
|
||||
JUnitPublicField
|
||||
JUnitPublicNonTestMethod
|
||||
JUnitPublicProperty
|
||||
JUnitSetUpCallsSuper
|
||||
JUnitStyleAssertions
|
||||
JUnitTearDownCallsSuper
|
||||
JUnitTestMethodWithoutAssert
|
||||
JUnitUnnecessarySetUp
|
||||
JUnitUnnecessaryTearDown
|
||||
JUnitUnnecessaryThrowsException
|
||||
|
||||
//JavaIoPackageAccess
|
||||
JdbcConnectionReference
|
||||
JdbcResultSetReference
|
||||
JdbcStatementReference
|
||||
|
||||
// Generally we've been pretty good about this, this warning only really
|
||||
// shows up for good descriptive exception messages
|
||||
//LineLength
|
||||
|
@ -187,9 +167,10 @@ ruleset {
|
|||
LoggingSwallowsStacktrace
|
||||
LongLiteralWithLowerCaseL
|
||||
MethodCount
|
||||
MethodName
|
||||
MethodName {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
MethodSize
|
||||
MisorderedStaticImports
|
||||
MissingBlankLineAfterImports
|
||||
MissingBlankLineAfterPackage
|
||||
MissingNewInThrowStatement
|
||||
|
@ -198,7 +179,9 @@ ruleset {
|
|||
NestedBlockDepth
|
||||
NestedForLoop
|
||||
NestedSynchronization
|
||||
NoDef
|
||||
NoDef {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
NoWildcardImports
|
||||
NonFinalPublicField
|
||||
NonFinalSubclassOfSensitiveInterface
|
||||
|
@ -225,9 +208,6 @@ ruleset {
|
|||
ReturnsNullInsteadOfEmptyCollection
|
||||
SerialPersistentFields
|
||||
SerialVersionUID
|
||||
/* Not needed
|
||||
SerializableClassMustDefineSerialVersionUID
|
||||
*/
|
||||
SimpleDateFormatMissingLocale
|
||||
SpaceAfterCatch
|
||||
SpaceAfterClosingBrace
|
||||
|
@ -239,8 +219,6 @@ ruleset {
|
|||
SpaceAfterSwitch
|
||||
SpaceAfterWhile
|
||||
SpaceAroundClosureArrow
|
||||
// I cannot get this rule to cooperate
|
||||
//SpaceAroundMapEntryColon
|
||||
SpaceAroundOperator
|
||||
SpaceBeforeClosingBrace
|
||||
SpaceBeforeOpeningBrace
|
||||
|
@ -276,10 +254,14 @@ ruleset {
|
|||
ThrowRuntimeException
|
||||
ThrowThrowable
|
||||
ToStringReturnsNull
|
||||
TrailingWhitespace
|
||||
TrailingWhitespace {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
UnnecessaryBigDecimalInstantiation
|
||||
UnnecessaryBigIntegerInstantiation
|
||||
UnnecessaryBooleanExpression
|
||||
UnnecessaryBooleanExpression {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
UnnecessaryBooleanInstantiation
|
||||
UnnecessaryCallForLastElement
|
||||
UnnecessaryCallToSubstring
|
||||
|
@ -297,7 +279,9 @@ ruleset {
|
|||
UnnecessaryFail
|
||||
UnnecessaryFinalOnPrivateMethod
|
||||
UnnecessaryFloatInstantiation
|
||||
UnnecessaryGString
|
||||
UnnecessaryGString {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
UnnecessaryGetter
|
||||
UnnecessaryGroovyImport
|
||||
UnnecessaryIfStatement
|
||||
|
@ -313,8 +297,6 @@ ruleset {
|
|||
UnnecessaryPackageReference
|
||||
UnnecessaryParenthesesForMethodCallWithClosure
|
||||
UnnecessaryPublicModifier
|
||||
// Return keywords are useful for code readability silly
|
||||
//UnnecessaryReturnKeyword
|
||||
UnnecessarySafeNavigationOperator
|
||||
UnnecessarySelfAssignment
|
||||
UnnecessarySemicolon
|
||||
|
@ -324,7 +306,6 @@ ruleset {
|
|||
UnnecessaryToString
|
||||
UnnecessaryTransientModifier
|
||||
UnsafeArrayDeclaration
|
||||
UnsafeImplementationAsMap
|
||||
UnusedArray
|
||||
UnusedImport
|
||||
UnusedMethodParameter
|
||||
|
@ -342,7 +323,9 @@ ruleset {
|
|||
UseCollectMany
|
||||
UseCollectNested
|
||||
UseOfNotifyMethod
|
||||
VariableName
|
||||
VariableName {
|
||||
doNotApplyToFileNames = '*Spec.groovy,*Specification.groovy'
|
||||
}
|
||||
VectorIsObsolete
|
||||
VolatileArrayField
|
||||
VolatileLongOrDoubleField
|
|
@ -1,23 +1,14 @@
|
|||
package com.github.jrubygradle.jar
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.junit.Rule
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.testkit.runner.GradleRunner
|
||||
import org.gradle.testkit.runner.TaskOutcome
|
||||
|
||||
import spock.lang.*
|
||||
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
import spock.lang.Ignore
|
||||
import spock.lang.Specification
|
||||
|
||||
/*
|
||||
* A series of tests which expect to use the JRubyJar task in more of an integration
|
||||
* test fashion, i.e. evaluating the Project, etc
|
||||
*/
|
||||
|
||||
@Ignore
|
||||
class JRubyJarIntegrationSpec extends Specification {
|
||||
static final File TESTROOT = new File("${System.getProperty('TESTROOT') ?: 'build/tmp/test/unittests'}/jrjps")
|
||||
|
|
|
@ -32,12 +32,12 @@ class JRubyJarTestKitSpec extends IntegrationSpecification {
|
|||
when:
|
||||
BuildResult result = build()
|
||||
|
||||
|
||||
then:
|
||||
result.task(":jrubyJar").outcome == TaskOutcome.SUCCESS
|
||||
new File(projectDir, "build/libs/testproject-jruby.jar").exists()
|
||||
}
|
||||
|
||||
@SuppressWarnings('GStringExpressionWithinString')
|
||||
void "executing the jrubyJar task produces an executable artifact"() {
|
||||
setup:
|
||||
withJRubyJarConfig """
|
||||
|
@ -71,6 +71,7 @@ class JRubyJarTestKitSpec extends IntegrationSpecification {
|
|||
}
|
||||
|
||||
@Issue("https://github.com/jruby-gradle/jruby-gradle-plugin/issues/183")
|
||||
@SuppressWarnings('GStringExpressionWithinString')
|
||||
void "creating a new task based on JRubyJar produces a jar artifact"() {
|
||||
setup:
|
||||
withAdditionalContent '''
|
||||
|
@ -97,6 +98,7 @@ class JRubyJarTestKitSpec extends IntegrationSpecification {
|
|||
|
||||
@IgnoreIf({ IntegrationSpecification.OFFLINE })
|
||||
@Issue('https://github.com/jruby-gradle/jruby-gradle-plugin/pull/271')
|
||||
@SuppressWarnings('GStringExpressionWithinString')
|
||||
def 'using a more recent jar-dependencies should work'() {
|
||||
setup:
|
||||
withRepoSetup """
|
||||
|
@ -233,6 +235,7 @@ class JRubyJarTestKitSpec extends IntegrationSpecification {
|
|||
gradleRunner(tasks).build()
|
||||
}
|
||||
|
||||
@SuppressWarnings('UnnecessaryDefInMethodDeclaration')
|
||||
private def getJarEntries() {
|
||||
ZipFile zip = new ZipFile("${projectDir}/build/libs/testproject-jruby.jar")
|
||||
zip.entries()
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.junit.rules.TemporaryFolder
|
|||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
class IntegrationSpecification extends Specification {
|
||||
static final boolean OFFLINE = System.getProperty('TESTS_ARE_OFFLINE')
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.github.jrubygradle.jar
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.ProjectConfigurationException
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.*
|
||||
|
||||
import static org.gradle.api.logging.LogLevel.LIFECYCLE
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
|
||||
/**
|
||||
* JRubyJar task's unit tests
|
||||
|
|
|
@ -9,7 +9,7 @@ class JRubyPluginInstanceSpec extends Specification {
|
|||
plugin = new JRubyJarPlugin()
|
||||
}
|
||||
|
||||
void "isJRubyVersionDeprecated()"() {
|
||||
void "isJRubyVersionDeprecated"() {
|
||||
expect:
|
||||
plugin.isJRubyVersionDeprecated(version) == expected
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.github.jrubygradle.war
|
||||
|
||||
|
||||
import org.gradle.api.tasks.bundling.War
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.Specification
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.github.jrubygradle.war
|
||||
|
||||
import org.gradle.testfixtures.ProjectBuilder
|
||||
import spock.lang.*
|
||||
import static org.gradle.api.logging.LogLevel.*
|
||||
import spock.lang.Specification
|
||||
|
||||
/**
|
||||
* @author R. Tyler Croy
|
||||
|
|
Loading…
Reference in New Issue