forked from dzhaughnroth/jasmine-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
executable file
·142 lines (125 loc) · 4.34 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import org.apache.tools.ant.filters.*
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.sourceforge.purrpackage:maven-oss-gradle-plugin:1.0"
}
}
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'maven-oss'
group = 'com.github.dzhaughnroth'
version = '0.5'
repositories {
mavenCentral();
}
dependencies {
compile "junit:junit:3.8.2"
groovy localGroovy()
compile "org.codehaus.groovy:groovy:1.7.8"
compile gradleApi()
compile "net.sourceforge.htmlunit:htmlunit:2.8"
}
afterEvaluate {
def prTasks = sourceSets.all.processResourcesTaskName.collect { tasks[it] };
prTasks.each( { it.configure( {
filter( ReplaceTokens, tokens: [version: project.version] )
} )
} );
}
task clearCache() {
doFirst {
File f = file( "${System.getProperty("user.home")}/.gradle/cache/${project.group}/${project.name}" )
println( "Deleting gradle cache at ${f.absolutePath}" );
delete( f );
}
}
def copyFile( from, to ) {
delete to;
to << from.text;
}
task cleanPluginTestArea( type: GradleBuild ) {
dependsOn test
dependsOn install
dependsOn clearCache
dir = "pluginTest"
tasks = ["clean", "jasmineGenerate" ]
startParameter.projectProperties.put( "pluginVersion", "${version}" );
startParameter.projectProperties.put( "anExclude", "" );
doLast {
assert !file( "${dir}/build" ).exists();
}
}
task pluginNotFailingTestTask( type: GradleBuild ) {
dependsOn cleanPluginTestArea
dir = "pluginTest"
tasks = [ "check"]
startParameter.projectProperties.put( "pluginVersion", "${version}" );
startParameter.projectProperties.put( "anExclude", "**/MultiRunner.html" );
doLast {
copyFile( file( "${dir}/build/jasmine-summary.html" ),
file( "${dir}/build/passingPluginTestTask-jasmine-summary.html" ) );
checkDir( dir, 0, 0, 1, false );
}
}
task pluginTestTask( type: GradleBuild ) {
dependsOn test
dependsOn install
dependsOn clearCache
dependsOn cleanPluginTestArea
dir = "pluginTest"
tasks = [ "check"]
startParameter.projectProperties.put( "pluginVersion", "${version}" )
startParameter.projectProperties.put( "anExclude", "" );
doLast {
copyFile( file( "${dir}/build/jasmine-summary.html" ),
file( "${dir}/build/failingPluginTestTask-jasmine-summary.html" ) );
checkDir( dir, 3, 1, 1, false );
}
}
task generatorTestTask( type: GradleBuild ) {
dependsOn test
dependsOn install
dependsOn clearCache
dir = "generatorTest"
tasks = ["clean", "jasmineGenerate", "check"]
startParameter.projectProperties.put( "pluginVersion", "${version}" );
doLast {
checkDir( dir, 2, 1, 0, true );
}
}
def checkDir( dir, specsFailed, pagesFailed, pagesPassed, jslintFailed ) {
def exists = file( "${dir}/build/jasmine.failures" ).exists();
assert exists == ( specsFailed > 0)
def jslintExists = file( "${dir}/build/jasmine.jslint.failures" ).exists();
assert jslintExists == jslintFailed;
assert file( "${dir}/build/jasmine" ).exists();
assert file( "${dir}/src/test/javascript/lib/MultiRunner.html" ).exists();
def f = file( "${dir}/build/jasmine-summary.html" );
assert f.exists();
def text = f.text;
assert specsFailed == (text =~ /Spec.*FAILED/).size();
assert pagesFailed == (text =~ /FAILED page/).size();
assert pagesPassed == (text =~ /Passed page/).size();
}
check.dependsOn( pluginTestTask );
check.dependsOn( pluginNotFailingTestTask );
check.dependsOn( generatorTestTask );
pomConfigurator.addDeveloper( "John Roth", "[email protected]" )
pomConfigurator.gnuLicense();
pomConfigurator.configurePom( {
it.pom {
project {
name "Jasmine Gradle Plugin"
description "Use Jasmine to test javascript both in situ and as part of a build"
url "https://github.com/dzhaughnroth/jasmine-gradle-plugin"
inceptionYear "2011"
scm {
url "http://github.com/dzhaughnroth/jasmine-gradle-plugin"
connection "scm:git://github.com/dzhaughnroth/jasmine-gradle-plugin"
developerConnection "scm:git://github.com/dzhaughnroth/jasmine-gradle-plugin"
}
}
} } );