blob: cf018738ca269c61e4bd2a20cfc854e0a845a00a [file] [log] [blame]
Cedric Beust0730d082015-05-10 21:52:20 -07001buildscript {
Cedric Beust29fe72f2015-05-25 22:01:11 -07002
3 def a_user = hasProperty('artifactory_user') ? artifactory_user : System.getenv('artifactory_user')
4 def a_password = hasProperty('artifactory_password') ? artifactory_password : System.getenv('artifactory_password')
5
Cedric Beust0730d082015-05-10 21:52:20 -07006 repositories {
7 mavenCentral()
8 jcenter()
9 maven {
10 url 'http://dl.bintray.com/cbeust/maven'
Cedric Beust576120b2015-05-25 21:02:31 -070011 }
12 maven {
13 url 'http://oss.jfrog.org/artifactory/plugins-release'
14 credentials {
Cedric Beust29fe72f2015-05-25 22:01:11 -070015 username = "${a_user}"
16 password = "${a_password}"
Cedric Beust576120b2015-05-25 21:02:31 -070017 }
18 }
19 }
20
21 dependencies {
22 //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
23 classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3"
Cedric Beust551ccd52015-07-14 11:09:17 -070024 classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
Julien Herr39aaf032015-10-31 15:22:40 +010025 classpath "com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3"
Cedric Beust0730d082015-05-10 21:52:20 -070026 }
27}
28
29plugins {
Cedric Beustef1fd542015-07-15 10:35:09 -070030 id "com.jfrog.bintray" version "1.2"
Cedric Beust84697c02015-07-11 15:01:41 -070031 id "com.jfrog.artifactory" version "3.1.1"
Julien Herr141d3ae2015-10-22 22:43:24 +020032 id "org.sonarqube" version "1.0"
Cedric Beust0730d082015-05-10 21:52:20 -070033}
34
Cedric Beust64349ff2015-10-27 00:13:23 -070035version = '6.9.10-SNAPSHOT'
Cedric Beust0730d082015-05-10 21:52:20 -070036
37apply plugin: 'java'
Julien Herr39aaf032015-10-31 15:22:40 +010038apply plugin: 'nebula.optional-base'
39apply plugin: 'nebula.provided-base'
Cedric Beustc642de62015-10-12 21:17:06 -070040
41targetCompatibility = "1.7"
42sourceCompatibility = "1.7"
43
Mathieu SEBIRE800cb342015-07-22 22:42:08 +020044apply plugin: 'osgi'
Cedric Beust0730d082015-05-10 21:52:20 -070045
46repositories {
47 mavenCentral()
48 jcenter()
49 maven {
50 url 'http://dl.bintray.com/cbeust/maven'
51 }
52}
53
54dependencies {
Julien Herra685f862015-10-31 15:23:54 +010055 compile 'org.beanshell:bsh:2.0b4'
56 compile 'com.beust:jcommander:1.48'
57
Julien Herr39aaf032015-10-31 15:22:40 +010058 compile 'org.apache.ant:ant:1.7.0', optional
59 compile 'junit:junit:4.10', optional
Julien Herr39aaf032015-10-31 15:22:40 +010060 compile 'org.yaml:snakeyaml:1.15', optional
Cedric Beust0730d082015-05-10 21:52:20 -070061
Julien Herra685f862015-10-31 15:23:54 +010062 provided 'com.google.inject:guice:4.0:no_aop'
63
Cedric Beust0730d082015-05-10 21:52:20 -070064 testCompile 'org.assertj:assertj-core:2.0.0'
65 testCompile 'org.testng:testng:6.9.4'
66}
67
68task sourceJar(type: Jar) {
69 group 'Build'
70 description 'An archive of the source code'
71 classifier 'sources'
72 from sourceSets.main.allSource
73}
74
75artifacts {
Cedric Beust0730d082015-05-10 21:52:20 -070076 sourceJar
77}
78
79import org.apache.tools.ant.filters.ReplaceTokens
80
Cedric Beust98fbd6d2015-05-11 13:53:55 -070081def generatedSourcesFolder = projectDir.toString() + '/src/generated/java'
82
83def dirFrom = projectDir.toString() + '/src/main/resources/org/testng/internal'
84def dirTo = generatedSourcesFolder + "/org/testng/internal"
85def fileFrom = 'VersionTemplateJava'
86def fileTo = 'Version.java'
87
Cedric Beust0730d082015-05-10 21:52:20 -070088task removeVersion {
Cedric Beust98fbd6d2015-05-11 13:53:55 -070089 delete dirTo + fileTo
Cedric Beust0730d082015-05-10 21:52:20 -070090}
91
Cedric Beust71f67972015-05-10 22:38:40 -070092sourceSets {
93 generated {
94 java {
95 srcDir 'src/generated/java'
96 }
97 resources {
98 srcDir 'src/generated/resources'
99 }
100 }
101}
Cedric Beust0730d082015-05-10 21:52:20 -0700102
Cedric Beust71f67972015-05-10 22:38:40 -0700103sourceSets {
104 main {
105 compileClasspath += generated.output
106 runtimeClasspath += generated.output
107 }
108}
Cedric Beust0730d082015-05-10 21:52:20 -0700109
Cedric Beust71f67972015-05-10 22:38:40 -0700110gradle.projectsEvaluated {
111 compileJava.dependsOn(myDir)
112}
113
Cedric Beust0730d082015-05-10 21:52:20 -0700114task myDir {
Cedric Beust98fbd6d2015-05-11 13:53:55 -0700115 delete dirTo + "/" + fileTo
116 mkdir(dirTo)
Cedric Beust0730d082015-05-10 21:52:20 -0700117}
118
Cedric Beust6583ca92015-05-23 12:16:18 -0700119// Include the generated Version.class in the jar
120jar {
Mathieu SEBIRE800cb342015-07-22 22:42:08 +0200121 manifest {
122 instruction 'Bundle-License', 'http://apache.org/licenses/LICENSE-2.0'
123 instruction 'Bundle-Description', 'TestNG is a testing framework.'
124 instruction 'Import-Package',
125 'bsh.*;version="[2.0.0,3.0.0)";resolution:=optional',
126 'com.beust.jcommander.*;version="[1.7.0,3.0.0)";resolution:=optional',
127 'com.google.inject.*;version="[1.2,1.3)";resolution:=optional',
128 'junit.framework;version="[3.8.1, 5.0.0)";resolution:=optional',
129 'org.junit.*;resolution:=optional',
130 'org.apache.tools.ant.*;version="[1.7.0, 2.0.0)";resolution:=optional',
131 'org.yaml.*;version="[1.6,2.0)";resolution:=optional',
132 '!com.beust.testng',
133 '!org.testng.*',
134 '!com.sun.*',
135 '*'
136 }
Cedric Beust6583ca92015-05-23 12:16:18 -0700137 from "$buildDir/classes/generated"
138}
139
Cedric Beust0730d082015-05-10 21:52:20 -0700140task createVersion(type: Copy, dependsOn: myDir) {
141 println("Creating Version file: ${version} in ${dirTo}")
Cedric Beust0730d082015-05-10 21:52:20 -0700142 from dirFrom
Cedric Beust98fbd6d2015-05-11 13:53:55 -0700143 include fileFrom
Cedric Beust0730d082015-05-10 21:52:20 -0700144 into(dirTo)
Cedric Beust98fbd6d2015-05-11 13:53:55 -0700145 rename(fileFrom, fileTo)
Cedric Beust0730d082015-05-10 21:52:20 -0700146 filter(ReplaceTokens, tokens: [version: version])
Cedric Beust71f67972015-05-10 22:38:40 -0700147}
148
149compileJava.dependsOn(createVersion)
150
151test {
152 useTestNG() {
153 suites 'src/test/resources/testng.xml'
154 }
Cedric Beust962f7ad2015-06-30 07:19:10 -0700155// testLogging.showStandardStreams = true
Krishnan Mahadevana9e2d612015-05-12 08:24:06 +0530156 systemProperties = System.getProperties()
157 systemProperties['test.resources.dir'] = 'build/resources/test/'
Cedric Beust0730d082015-05-10 21:52:20 -0700158}
Cedric Beust8771b432015-05-31 14:15:43 -0700159
160if (JavaVersion.current().isJava8Compatible()) {
161 allprojects {
162 tasks.withType(Javadoc) {
163 options.addStringOption('Xdoclint:none', '-quiet')
164 }
165 }
166}
Cedric Beust01794392015-07-11 16:20:39 -0700167
Julien Herr141d3ae2015-10-22 22:43:24 +0200168sonarqube {
169 properties {
170 property "sonar.host.url", "http://nemo.sonarqube.org"
171 property "sonar.analysis.mode", "preview"
172 property "sonar.github.repository", "cbeust/testng"
173 property "sonar.github.login", "testng-bot"
174 }
175}
176
Cedric Beust01794392015-07-11 16:20:39 -0700177apply from: 'gradle/publishing.gradle'