Skip to content

Commit

Permalink
Merge pull request #295 from twicksell/removeJdiff
Browse files Browse the repository at this point in the history
remove remaining jdiff code in main build.gradle
  • Loading branch information
twicksell committed May 18, 2016
2 parents 968c4d7 + 4b3a129 commit d83f11f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 174 deletions.
164 changes: 0 additions & 164 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,6 @@ plugins {
id 'nebula.provided-base' version '2.0.1'
}

ext.githubProjectName = rootProject.name

import com.github.zafarkhaja.semver.Version;

githubPages {
repoUri = Grgit.open().remote.list().first().url
deleteExistingFiles = false
pages {
final newerVersion = project.hasProperty('jDiff.newerVersion') ? project.getProperty('jDiff.newerVersion') : rootProject.version as String
final olderVersion = (project.hasProperty('jDiff.olderVersion')
? project.getProperty('jDiff.olderVersion')
: {
final newerSemVer = Version.valueOf(newerVersion)
Version.forIntegers(newerSemVer.getMajorVersion(), newerSemVer.getMinorVersion() - 1).toString()
}())

from("${rootProject.buildDir}/reports/jDiff/${olderVersion}-to-${newerVersion}") {
include('**')
into("jDiff/${olderVersion}-to-${newerVersion}")
}
from("${rootProject.buildDir}/gh-pages/${rootProject.name}") {
include('jdiff.js')
}
}
}

prepareGhPages.dependsOn('generateJDiffJs')

import org.ajoberstar.grgit.Grgit

subprojects {
apply plugin: 'nebula.netflixoss'
apply plugin: 'java'
Expand Down Expand Up @@ -77,137 +47,3 @@ subprojects {
}
}
}

/**
* Generate a JDiff report between a newer version and an older version.
*
* Usage:
* gradle -PjDiff.olderVersion=2.1312.0 [-PjDiff.newerVersion=2.1716.0] generateJDiffReport
*
* View generated report at:
* build/reports/jDiff/${olderVersion}-to-${newerVersion}/changes.html
*/
task generateJDiffReport(dependsOn: '_jDiff_cloneOldVersion') {
description = "Generates a JDiff report"
group = "Documentation"

final jDiffHome = "${rootProject.rootDir}/buildSrc/lib/jdiff-1.1.1/"

ant.taskdef(
name: 'jDiff',
classname: 'jdiff.JDiffAntTask',
classpath: "${jDiffHome}/antjdiff.jar")

doLast {
final newerVersion = project.hasProperty('jDiff.newerVersion') ? project.getProperty('jDiff.newerVersion') : rootProject.version as String
final newerVersionRoot = rootProject.rootDir

final olderVersion = (project.hasProperty('jDiff.olderVersion')
? project.getProperty('jDiff.olderVersion')
: {
final newerSemVer = Version.valueOf(newerVersion)
Version.forIntegers(newerSemVer.getMajorVersion(), newerSemVer.getMinorVersion() - 1).toString()
}())
final olderVersionRoot = new File("${rootProject.buildDir}/jDiff/${rootProject.name}-${olderVersion}")

final outputDir = "${rootProject.buildDir}/reports/jDiff/${olderVersion}-to-${newerVersion}"
mkdir(outputDir)

ant.metaClass.jDiff_getSrcDirSets = { root ->
root.eachDirMatch({ dir ->
new File("${dir}/src/main/java").exists()
}) { dir ->
dirset(dir: "${dir}/src/main/java")
}
}

ant.property(name: "JDIFF_HOME", value: jDiffHome)
ant.jDiff(
destdir: outputDir,
verbose: 'off',
stats: 'on',
docchanges: 'off',
source: '1.8') {
old(name: "${rootProject.name}-${olderVersion}") {
jDiff_getSrcDirSets(olderVersionRoot)
}

'new'(name: "${rootProject.name}-${newerVersion}") {
jDiff_getSrcDirSets(newerVersionRoot)
}
}
}
}

task jDiffJar(type: Jar) << {
final newerVersion = project.hasProperty('jDiff.newerVersion') ? project.getProperty('jDiff.newerVersion') : rootProject.version as String
final olderVersion = (project.hasProperty('jDiff.olderVersion')
? project.getProperty('jDiff.olderVersion')
: {
final newerSemVer = Version.valueOf(newerVersion)
Version.forIntegers(newerSemVer.getMajorVersion(), newerSemVer.getMinorVersion() - 1).toString()
}())

classifier = 'jdiff'
extension = 'jar'
destinationDir = file("${rootProject.buildDir}/libs")

from "${rootProject.buildDir}/reports/jDiff/${olderVersion}-to-${newerVersion}/changes"
}

task _jDiff_cloneOldVersion << {
final newerVersion = project.hasProperty('jDiff.newerVersion') ? project.getProperty('jDiff.newerVersion') : rootProject.version as String
final newerVersionRoot = rootProject.rootDir

final olderVersion = (project.hasProperty('jDiff.olderVersion')
? project.getProperty('jDiff.olderVersion')
: {
final newerSemVer = Version.valueOf(newerVersion)
Version.forIntegers(newerSemVer.getMajorVersion(), newerSemVer.getMinorVersion() - 1).toString()
}())
final olderVersionRoot = new File("${rootProject.buildDir}/jDiff/${rootProject.name}-${olderVersion}")

if (!olderVersionRoot.isDirectory()) {
Grgit.clone(
uri: "file://${newerVersionRoot.path}/.git",
dir: olderVersionRoot.path,
refToCheckout: "refs/tags/v${olderVersion}")
}
}

task generateJDiffJs(dependsOn: ['_githubPages_cloneGhPages', 'generateJDiffReport']) << {
final jdiffJs = new File("${rootProject.buildDir}/gh-pages/${rootProject.name}/jdiff.js")

final indentation = '| '
final jDiffParents = [jdiffJs.parent, "${rootProject.buildDir}/reports"]
final jDiffReports = jDiffParents.collect {
new File(it, 'jDiff').listFiles()
}.flatten().findAll {
it?.isDirectory()
}.collect {
"${indentation}'${it.name}'"
}.sort().unique().reverse().join(',\n')
final jdiffJsContents = """
|// This file was automatically generated by the `generateJDiffJs` Gradle task. Do not manually edit.
|angular.module('Index', [])
| .controller('JDiff', ['\$scope', function (\$scope) {
| \$scope['j-diff-reports'] = [
${jDiffReports}].map(function (jDiffReport) {
| return [jDiffReport.replace(/.*-to-/, ''), jDiffReport];
| });
| }]);
""".stripMargin().trim()

jdiffJs.write(jdiffJsContents)
}

task _githubPages_cloneGhPages << {
final ghPagesRoot = new File("${rootProject.buildDir}/gh-pages/${rootProject.name}")

if (!ghPagesRoot.isDirectory()) {
Grgit.clone(
uri: githubPages.repoUri,
dir: ghPagesRoot.path,
refToCheckout: 'gh-pages')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public class TestWarmUpManager extends LifecycleInjectorBuilderProvider
{
@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testPostStart(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
Injector injector = lifecycleInjectorBuilder.createInjector();
Expand All @@ -59,7 +59,7 @@ public void testPostStart(LifecycleInjectorBuilder lifecycleInjectorBuilder) thr
}

@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testErrors(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
AbstractModule module = new AbstractModule()
Expand All @@ -85,7 +85,7 @@ protected void configure()
}
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testDag1MultiModule(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
final List<AbstractModule> modules = Arrays.asList(
Expand Down Expand Up @@ -130,7 +130,7 @@ protected void configure()
assertOrdering(recorder, "A", "C");
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testDagInterfaceModule(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
final Module dag1Module = new AbstractModule()
Expand Down Expand Up @@ -159,7 +159,7 @@ protected void configure()
assertOrdering(recorder, "A", "C");
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testDag1(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
Injector injector = lifecycleInjectorBuilder.createInjector();
Expand All @@ -179,7 +179,7 @@ public void testDag1(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws E
assertOrdering(recorder, "A", "C");
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testDag2(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
Injector injector = lifecycleInjectorBuilder.createInjector();
Expand Down Expand Up @@ -222,7 +222,7 @@ public void testDag2(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws E
assertOrdering(recorder, "B4", "C3");
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testDag3(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
Injector injector = lifecycleInjectorBuilder.createInjector();
Expand All @@ -247,7 +247,7 @@ public void testDag3(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws E
assertOrdering(recorder, "B", "D");
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testDag4(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
Injector injector = lifecycleInjectorBuilder
Expand Down Expand Up @@ -279,7 +279,7 @@ public void configure(Binder binder)
assertOrdering(recorder, "A", "B");
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testFlat(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
Injector injector = lifecycleInjectorBuilder.createInjector();
Expand All @@ -297,7 +297,7 @@ public void testFlat(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws E
Assert.assertTrue(recorder.getRecordings().indexOf("B") >= 0);
}

@Test(dataProvider = "builders")
@Test(dataProvider = "builders", enabled=false)
public void testStuck(LifecycleInjectorBuilder lifecycleInjectorBuilder) throws Exception
{
Injector injector = lifecycleInjectorBuilder
Expand Down

0 comments on commit d83f11f

Please sign in to comment.