aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: cf018738ca269c61e4bd2a20cfc854e0a845a00a (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
buildscript {

    def a_user = hasProperty('artifactory_user') ? artifactory_user : System.getenv('artifactory_user')
    def a_password = hasProperty('artifactory_password') ? artifactory_password : System.getenv('artifactory_password')

    repositories {
        mavenCentral()
        jcenter()
        maven {
            url 'http://dl.bintray.com/cbeust/maven'
        }
        maven {
            url 'http://oss.jfrog.org/artifactory/plugins-release'
            credentials {
                username = "${a_user}"
                password = "${a_password}"
            }
        }
    }

    dependencies {
        //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3"
        classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
        classpath "com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3"
    }
}

plugins {
    id "com.jfrog.bintray" version "1.2"
    id "com.jfrog.artifactory" version "3.1.1"
    id "org.sonarqube" version "1.0"
}

version = '6.9.10-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'nebula.optional-base'
apply plugin: 'nebula.provided-base'

targetCompatibility = "1.7"
sourceCompatibility = "1.7"

apply plugin: 'osgi'

repositories {
    mavenCentral()
    jcenter()
    maven {
        url 'http://dl.bintray.com/cbeust/maven'
    }
}

dependencies {
    compile 'org.beanshell:bsh:2.0b4'
    compile 'com.beust:jcommander:1.48'

    compile 'org.apache.ant:ant:1.7.0', optional
    compile 'junit:junit:4.10', optional
    compile 'org.yaml:snakeyaml:1.15', optional

    provided 'com.google.inject:guice:4.0:no_aop'

    testCompile 'org.assertj:assertj-core:2.0.0'
    testCompile 'org.testng:testng:6.9.4'
}

task sourceJar(type: Jar) {
    group 'Build'
    description 'An archive of the source code'
    classifier 'sources'
    from sourceSets.main.allSource
}

artifacts {
    sourceJar
}

import org.apache.tools.ant.filters.ReplaceTokens

def generatedSourcesFolder = projectDir.toString() + '/src/generated/java'

def dirFrom = projectDir.toString() + '/src/main/resources/org/testng/internal'
def dirTo = generatedSourcesFolder + "/org/testng/internal"
def fileFrom = 'VersionTemplateJava'
def fileTo = 'Version.java'

task removeVersion {
    delete dirTo + fileTo
}

sourceSets {
    generated {
        java {
            srcDir 'src/generated/java'
        }
        resources {
            srcDir 'src/generated/resources'
        }
    }
}

sourceSets {
    main {
        compileClasspath += generated.output
        runtimeClasspath += generated.output
    }
}

gradle.projectsEvaluated {
    compileJava.dependsOn(myDir)
}

task myDir {
    delete dirTo + "/" + fileTo
    mkdir(dirTo)
}

// Include the generated Version.class in the jar
jar {
    manifest {
        instruction 'Bundle-License', 'http://apache.org/licenses/LICENSE-2.0'
        instruction 'Bundle-Description', 'TestNG is a testing framework.'
        instruction 'Import-Package',
            'bsh.*;version="[2.0.0,3.0.0)";resolution:=optional',
            'com.beust.jcommander.*;version="[1.7.0,3.0.0)";resolution:=optional',
            'com.google.inject.*;version="[1.2,1.3)";resolution:=optional',
            'junit.framework;version="[3.8.1, 5.0.0)";resolution:=optional',
            'org.junit.*;resolution:=optional',
            'org.apache.tools.ant.*;version="[1.7.0, 2.0.0)";resolution:=optional',
            'org.yaml.*;version="[1.6,2.0)";resolution:=optional',
            '!com.beust.testng',
            '!org.testng.*',
            '!com.sun.*',
            '*'
    }
    from "$buildDir/classes/generated"
}

task createVersion(type: Copy, dependsOn: myDir) {
    println("Creating Version file: ${version} in ${dirTo}")
    from dirFrom
    include fileFrom
    into(dirTo)
    rename(fileFrom, fileTo)
    filter(ReplaceTokens, tokens: [version: version])
}

compileJava.dependsOn(createVersion)

test {
    useTestNG() {
        suites 'src/test/resources/testng.xml'
    }
//    testLogging.showStandardStreams = true
    systemProperties = System.getProperties()
    systemProperties['test.resources.dir'] = 'build/resources/test/'
}

if (JavaVersion.current().isJava8Compatible()) {
    allprojects {
        tasks.withType(Javadoc) {
            options.addStringOption('Xdoclint:none', '-quiet')
        }
    }
}

sonarqube {
    properties {
        property "sonar.host.url", "http://nemo.sonarqube.org"
        property "sonar.analysis.mode", "preview"
        property "sonar.github.repository", "cbeust/testng"
        property "sonar.github.login", "testng-bot"
    }
}

apply from: 'gradle/publishing.gradle'