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

Commit

Permalink
Merge pull request #182 from novoda/develop
Browse files Browse the repository at this point in the history
Release 0.8.1
  • Loading branch information
tasomaniac authored Mar 10, 2019
2 parents 5010351 + 3dc2203 commit 0ef4a03
Show file tree
Hide file tree
Showing 24 changed files with 179 additions and 117 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Change Log
==========

[Version 0.8.1](https://github.com/novoda/gradle-static-analysis-plugin/releases/tag/v0.8.1)
--------------------------

- Removed use of `classesDir` because deprecated in Gradle 5.x ([PR#174](https://github.com/novoda/gradle-static-analysis-plugin/pull/174),
[PR#178](https://github.com/novoda/gradle-static-analysis-plugin/pull/178),
[PR#179](https://github.com/novoda/gradle-static-analysis-plugin/pull/179),
[PR#180](https://github.com/novoda/gradle-static-analysis-plugin/pull/180))
- Included new versions of Ktlint in functional tests ([PR#167](https://github.com/novoda/gradle-static-analysis-plugin/pull/167))
- Added automatic tagging of snapshot releases ([PR#176](https://github.com/novoda/gradle-static-analysis-plugin/pull/176))


[Version 0.8](https://github.com/novoda/gradle-static-analysis-plugin/releases/tag/v0.8)
--------------------------

Expand Down
63 changes: 40 additions & 23 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ ext {
websiteUrl = 'https://github.com/novoda/gradle-static-analysis-plugin'
}

version = '0.8'
String tag = "v$project.version"
version = '0.8.1'
groovydoc.docTitle = 'Static Analysis Plugin'

apply plugin: 'com.novoda.build-properties'
Expand Down Expand Up @@ -36,17 +35,9 @@ buildProperties {
}
using(bintrayCredentials()).or(cli)
description = '''This should contain the following properties:
| - bintrayRepo: name of the repo of the organisation to deploy the artifacts to
| - bintrayUser: name of the account used to deploy the artifacts
| - bintrayKey: API key of the account used to deploy the artifacts
'''.stripMargin()
}

publish {
def generateVersion = {
return isSnapshot() ? "SNAPSHOT-${System.getenv('BUILD_NUMBER') ?: 'LOCAL'}" : project.version
}
using(['version': "${generateVersion()}"]).or(buildProperties.bintray)
- bintrayRepo: name of the repo of the organisation to deploy the artifacts to
- bintrayUser: name of the account used to deploy the artifacts
- bintrayKey: API key of the account used to deploy the artifacts'''.stripIndent()
}

}
Expand All @@ -59,11 +50,11 @@ publish {
groupId = 'com.novoda'
artifactId = 'gradle-static-analysis-plugin'
desc = 'Easy setup of static analysis tools for Android and Java projects.'
publishVersion = buildVersion

repoName = project.buildProperties.publish['bintrayRepo'].string
publishVersion = project.buildProperties.publish['version'].string
bintrayUser = project.buildProperties.publish['bintrayUser'].string
bintrayKey = project.buildProperties.publish['bintrayKey'].string
repoName = project.buildProperties.bintray['bintrayRepo'].string
bintrayUser = project.buildProperties.bintray['bintrayUser'].string
bintrayKey = project.buildProperties.bintray['bintrayKey'].string
website = project.websiteUrl
}

Expand Down Expand Up @@ -130,23 +121,34 @@ task prepareRelease {

String extractChangelog() {
String fullChangelog = rootProject.file('CHANGELOG.md').text
def latestChangelog = (fullChangelog =~ /\[Version ${project.version}.*\n-*([\s\S]*?)\[Version.*\n-*/)
def latestChangelog = (fullChangelog =~ /\[Version ${buildVersion}.*\n-*([\s\S]*?)\[Version.*\n-*/)
if (latestChangelog.size() > 0) {
return latestChangelog[0][1].trim()
}

def firstChangelog = (fullChangelog =~ /\[Version ${project.version}.*\n-*([\s\S]*)/)
def firstChangelog = (fullChangelog =~ /\[Version ${buildVersion}.*\n-*([\s\S]*)/)
if (firstChangelog.size() > 0) {
return firstChangelog[0][1].trim()
}
throw new GradleException("No changelog found for version $project.version")
throw new GradleException("No changelog found for version $buildVersion")
}

task printChangelog {
group = 'help'
description = "Print the provisional changelog for version $project.version"
description = "Print the provisional changelog for version $buildVersion"
doLast {
println "\nChangelog for version $buildVersion:\n${extractChangelog()}\n"
}
}

task prepareSnapshot {
description = 'Prepare changelog and tag for snapshot'
group = 'release'
dependsOn prepareGhCredentials
doLast {
println "\nChangelog for version $project.version:\n${extractChangelog()}\n"
grgit.tag.add {
name = tag
}
}
}

Expand All @@ -171,7 +173,14 @@ task publishRelease {
dependsOn publishArtifact
} else {
dependsOn publishArtifact
if (!isSnapshot()) {
if (isSnapshot()) {
dependsOn prepareSnapshot
doLast {
grgit.push {
tags = true
}
}
} else {
dependsOn prepareRelease, publishGroovydoc, publishPlugins
doLast {
grgit.push {
Expand All @@ -189,3 +198,11 @@ boolean isDryRun() {
boolean isSnapshot() {
buildProperties.cli['bintraySnapshot'].or(false).boolean
}

String getBuildVersion() {
return isSnapshot() ? "SNAPSHOT-${System.getenv('BUILD_NUMBER') ?: 'LOCAL'}" : project.version
}

String getTag() {
return buildVersion
}
2 changes: 0 additions & 2 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'groovy'
apply plugin: 'java-gradle-plugin'
apply from: rootProject.file('gradle/publish.gradle')

sourceSets {
Expand Down Expand Up @@ -29,5 +28,4 @@ dependencies {
testCompile libraries.findbugs.annotations
testCompile libraries.mockito

testRuntime files(pluginUnderTestMetadata)
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class FindbugsConfigurator extends CodeQualityConfigurator<FindBugs, FindBugsExt
}

private FileCollection getAndroidClasses(Object variant, List<String> includes) {
includes.isEmpty() ? project.files() : project.fileTree(variant.javaCompile.destinationDir).include(includes)
includes.isEmpty() ? project.files() : project.fileTree(variant.javaCompile.destinationDir).include(includes) as ConfigurableFileTree
}

@Override
Expand Down Expand Up @@ -118,17 +118,16 @@ 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 FileCollection createClassesTreeFrom(SourceSet sourceSet, List<String> includes) {
return sourceSet.output.classesDirs.inject(null) { ConfigurableFileTree cumulativeTree, File classesDir ->
def tree = project.fileTree(classesDir)
.builtBy(sourceSet.output)
.include(includes) as ConfigurableFileTree
cumulativeTree?.plus(tree) ?: tree
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ 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'],
]*.toArray()
}

Expand Down
72 changes: 36 additions & 36 deletions plugin/src/test/groovy/com/novoda/test/DeployRulesTestRule.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ class DeployRulesTestRule implements TestRule {
void evaluate() throws Throwable {
cleanRepo()
File projectDir = createProjectDir("${System.currentTimeMillis()}")
createBuildScript(projectDir)
createBuildScripts(projectDir)
GradleRunner.create()
.withProjectDir(projectDir)
.withDebug(true)
.forwardStdOutput(new OutputStreamWriter(System.out))
.forwardStdError(new OutputStreamWriter(System.out))
.withArguments('clean', 'publish')
.forwardOutput()
.build()
base.evaluate()
projectDir.deleteDir()
Expand All @@ -46,40 +45,41 @@ class DeployRulesTestRule implements TestRule {
}
}

private void createBuildScript(File projectDir) {
private void createBuildScripts(File projectDir) {
new File(projectDir, 'build.gradle').text = """
buildscript {
repositories {
jcenter()
}
}
version='$version'
apply plugin: 'java'
sourceSets {
main {
resources {
srcDirs = ${resourceDirs.collect { "'$it.path'" }}
}
}
}
apply plugin: 'maven-publish'
publishing {
repositories {
maven { url '${repoDir}' }
}
publications {
mavenJava(MavenPublication) {
groupId '$groupId'
artifactId '$artifactId'
from components.java
}
}
}"""
buildscript {
repositories {
jcenter()
}
}
version='$version'
apply plugin: 'java'
sourceSets {
main {
resources {
srcDirs = ${resourceDirs.collect { "'$it.path'" }}
}
}
}
apply plugin: 'maven-publish'
publishing {
repositories {
maven { url '${repoDir}' }
}
publications {
mavenJava(MavenPublication) {
groupId '$groupId'
artifactId '$artifactId'
from components.java
}
}
}""".stripIndent()
new File(projectDir, 'settings.gradle').text = ''''''
}

private static File createProjectDir(String path) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/test/groovy/com/novoda/test/Fixtures.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.google.common.io.Resources

public final class Fixtures {
private static final Exception NO_INSTANCE_ALLOWED = new UnsupportedOperationException("No instance allowed");
private static final File ROOT_DIR = new File(Resources.getResource('.').file).parentFile.parentFile.parentFile.parentFile
public static final File ROOT_DIR = new File(Resources.getResource('.').file).parentFile.parentFile.parentFile.parentFile
private static final File FIXTURES_DIR = new File(ROOT_DIR, 'src/test/fixtures')
private static final File SOURCES_DIR = new File(FIXTURES_DIR, 'sources')
private static final File REPORTS_DIR = new File(FIXTURES_DIR, 'reports')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.20'
classpath 'com.novoda:gradle-static-analysis-plugin:local'
}
}
plugins {
${formatPlugins(project)}
id 'com.novoda.static-analysis'
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.novoda.static-analysis'
android {
compileSdkVersion 27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.novoda:gradle-static-analysis-plugin:local'
}
}
plugins {
${formatPlugins(project)}
id 'com.novoda.static-analysis'
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.static-analysis'
android {
compileSdkVersion 27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ final class TestJavaProject extends TestProject<TestJavaProject> {

private static final Closure<String> TEMPLATE = { TestProject project ->
"""
buildscript {
dependencies {
classpath 'com.novoda:gradle-static-analysis-plugin:local'
}
}
plugins {
${formatPlugins(project)}
id 'com.novoda.static-analysis'
}
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'com.novoda.static-analysis'
sourceSets {
${formatSourceSets(project)}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.novoda:gradle-static-analysis-plugin:local'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.10'
}
}
plugins {
${formatPlugins(project)}
id 'com.novoda.static-analysis'
}
apply plugin: 'kotlin'
apply plugin: 'com.novoda.static-analysis'
repositories {
jcenter()
Expand Down
Loading

0 comments on commit 0ef4a03

Please sign in to comment.