org.gradle.scala.compile.UpToDateScalaCompileIntegrationTest.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.scala.compile
import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import org.gradle.integtests.fixtures.AvailableJavaHomes
import org.gradle.util.Requires
import spock.lang.Unroll
import static org.gradle.api.JavaVersion.VERSION_1_7
import static org.gradle.api.JavaVersion.VERSION_1_8
@Unroll
class UpToDateScalaCompileIntegrationTest extends AbstractIntegrationSpec {
def setup() {
file('src/main/scala/Person.scala') << "class Person(name: String)"
}
def "compile is out of date when changing the #changedVersion version"() {
buildScript(scalaProjectBuildScript(defaultZincVersion, defaultScalaVersion))
when:
run 'compileScala'
then:
executedAndNotSkipped ':compileScala'
when:
run 'compileScala'
then:
skipped ':compileScala'
when:
buildScript(scalaProjectBuildScript(newZincVersion, newScalaVersion))
run 'compileScala'
then:
executedAndNotSkipped ':compileScala'
where:
newScalaVersion | newZincVersion
'2.11.8' | '0.3.12'
'2.11.9' | '0.3.13'
defaultScalaVersion = '2.11.8'
defaultZincVersion = '0.3.13'
changedVersion = defaultScalaVersion != newScalaVersion ? 'scala' : 'zinc'
}
@Requires(adhoc = { AvailableJavaHomes.getJdk(VERSION_1_7) && AvailableJavaHomes.getJdk(VERSION_1_8) })
def "compile is out of date when changing the java version"() {
def jdk7 = AvailableJavaHomes.getJdk(VERSION_1_7)
def jdk8 = AvailableJavaHomes.getJdk(VERSION_1_8)
buildScript(scalaProjectBuildScript('0.3.13', '2.11.8'))
when:
executer.withJavaHome(jdk7.javaHome)
run 'compileScala'
then:
executedAndNotSkipped(':compileScala')
when:
executer.withJavaHome(jdk7.javaHome)
run 'compileScala'
then:
skipped ':compileScala'
when:
executer.withJavaHome(jdk8.javaHome)
run 'compileScala', '--info'
then:
executedAndNotSkipped(':compileScala')
}
def scalaProjectBuildScript(String zincVersion, String scalaVersion) {
return """
apply plugin: 'scala'
${jcenterRepository()}
dependencies {
zinc "com.typesafe.zinc:zinc:${zincVersion}"
compile "org.scala-lang:scala-library:${scalaVersion}"
}
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
""".stripIndent()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy