Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

[WIP] Upgrade gradle to 5 #169

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ subprojects {
}

wrapper {
gradleVersion = '4.10.2'
gradleVersion = '5.2.1'
distributionType = Wrapper.DistributionType.ALL
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
tasomaniac marked this conversation as resolved.
Show resolved Hide resolved
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package com.novoda.staticanalysis.internal.findbugs
import com.novoda.staticanalysis.Violations
import com.novoda.staticanalysis.internal.CodeQualityConfigurator
import org.gradle.api.Action
import org.gradle.api.GradleException
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.ConfigurableFileTree
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileTree
import org.gradle.api.plugins.quality.FindBugs
import org.gradle.api.plugins.quality.FindBugsExtension
import org.gradle.api.tasks.SourceSet
Expand Down Expand Up @@ -118,17 +120,27 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
}

private FileCollection getJavaClasses(SourceSet sourceSet, List<String> includes) {
includes.isEmpty() ? project.files() : createClassesTreeFrom(sourceSet).include(includes)
includes.isEmpty() ? project.files() : createClassesTreeFrom(sourceSet, includes)
}

/**
* The simple "classes = sourceSet.output" may lead to non-existing resources directory
* being passed to FindBugs Ant task, resulting in an error
* */
private ConfigurableFileTree createClassesTreeFrom(SourceSet sourceSet) {
project.fileTree(sourceSet.output.classesDir, {
it.builtBy(sourceSet.output)
})
private FileTree createClassesTreeFrom(SourceSet sourceSet, List<String> includes) {
def fileTrees = sourceSet.output.classesDirs.collect { classesDir ->
project.fileTree(classesDir) {
builtBy(sourceSet.output)
include(includes)
}
}
if (fileTrees.isEmpty()) {
throw GradleException("No file tree from ${sourceSet} and filters: ${includes}")
} else if (fileTrees.size() == 1) {
fileTrees.first()
} else {
fileTrees.inject(fileTrees.head()) { result, current -> result + current }
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ class KtlintIntegrationTest {
[TestProjectRule.forAndroidKotlinProject(), '6.2.1', 'ktlintMainCheck.txt'],
[TestProjectRule.forKotlinProject(), '6.3.1', 'ktlintMainCheck.txt'],
[TestProjectRule.forAndroidKotlinProject(), '6.3.1', 'ktlintMainCheck.txt'],
[TestProjectRule.forKotlinProject(), '7.0.0', 'ktlintMainSourceSetCheck.txt'],
[TestProjectRule.forAndroidKotlinProject(), '7.0.0', 'ktlintMainSourceSetCheck.txt'],
// [TestProjectRule.forKotlinProject(), '7.0.0', 'ktlintMainSourceSetCheck.txt'], // Broken because of https://github.com/JLLeitschuh/ktlint-gradle/issues/201
// [TestProjectRule.forAndroidKotlinProject(), '7.0.0', 'ktlintMainSourceSetCheck.txt'], // Broken because of https://github.com/JLLeitschuh/ktlint-gradle/issues/201
[TestProjectRule.forKotlinProject(), '7.1.0', 'ktlintMainSourceSetCheck.txt'],
[TestProjectRule.forAndroidKotlinProject(), '7.1.0', 'ktlintMainSourceSetCheck.txt'],
]*.toArray()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ class DeployRulesTestRule implements TestRule {
cleanRepo()
File projectDir = createProjectDir("${System.currentTimeMillis()}")
createBuildScript(projectDir)
createGradleSettings(projectDir)
GradleRunner.create()
.withProjectDir(projectDir)
.withDebug(true)
.withTestKitDir(new File(projectDir, "test-kit"))
.forwardStdOutput(new OutputStreamWriter(System.out))
.forwardStdError(new OutputStreamWriter(System.out))
.withArguments('clean', 'publish')
Expand All @@ -46,6 +48,10 @@ class DeployRulesTestRule implements TestRule {
}
}

private static void createGradleSettings(File projectDir) {
new File(projectDir, 'settings.gradle').text = ""
}

private void createBuildScript(File projectDir) {
new File(projectDir, 'build.gradle').text = """
buildscript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.20'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20'
}
}
plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.3.2'
}
}
plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.10'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20'
}
}

Expand Down
13 changes: 13 additions & 0 deletions plugin/src/test/groovy/com/novoda/test/TestProject.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ ${project.additionalConfiguration}
this.gradleRunner = GradleRunner.create()
.withProjectDir(projectDir)
.withPluginClasspath()
.withTestKitDir(new File(projectDir, "test-kit"))
pablisco marked this conversation as resolved.
Show resolved Hide resolved
.forwardStdOutput(new OutputStreamWriter(System.out))
.forwardStdError(new OutputStreamWriter(System.out))
createGradleSettings()
createGradleProperties()
}

private static File createProjectDir(String path) {
Expand All @@ -43,6 +46,16 @@ ${project.additionalConfiguration}
return dir
}

void createGradleSettings() {
write("", 'settings.gradle')
}

void createGradleProperties() {
write("""
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
tasomaniac marked this conversation as resolved.
Show resolved Hide resolved
""", 'gradle.properties')
}

List<String> defaultArguments() {
Collections.emptyList()
}
Expand Down
2 changes: 1 addition & 1 deletion sample-multi-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.novoda:gradle-static-analysis-plugin:local'
classpath 'io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0-RC12'
classpath 'gradle.plugin.org.jlleitschuh.gradle:ktlint-gradle:5.1.0'
Expand Down
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
buildscript {
ext.kotlin_version = '1.3.0'
ext.kotlin_version = '1.3.20'

repositories {
google()
gradlePluginPortal()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.novoda:gradle-static-analysis-plugin:local'
classpath 'io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0-RC12'
classpath 'gradle.plugin.org.jlleitschuh.gradle:ktlint-gradle:5.1.0'
Expand All @@ -24,6 +24,6 @@ subprojects {
}

wrapper {
gradleVersion = '4.10.2'
gradleVersion = '5.2.1'
distributionType = Wrapper.DistributionType.ALL
}
Binary file modified sample/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sample/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
pablisco marked this conversation as resolved.
Show resolved Hide resolved
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion sample/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
2 changes: 1 addition & 1 deletion sample/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down