-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.gradle
124 lines (101 loc) · 3.05 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
apply plugin: 'java'
apply plugin: "jacoco"
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'gradle-one-jar'
apply plugin: 'application'
sourceCompatibility = 1.7
// The main class of the application
mainClassName = 'com.blackducksoftware.ohcount4j.Ohcount'
archivesBaseName="${name.replaceAll('\\.', '-').toLowerCase()}"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.rholder:gradle-one-jar:1.0.4'
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'args4j:args4j:2.0.16'
compile 'net.java.dev.jna:jna:3.3.0'
compile 'commons-io:commons-io:2.4'
compile 'org.slf4j:slf4j-api:1.7.14'
compile 'org.slf4j:slf4j-log4j12:1.7.14'
compile 'com.googlecode.java-diff-utils:diffutils:1.3.0'
compile 'org.apache.commons:commons-lang3:3.4'
testCompile 'org.mockito:mockito-all:1.9.0'
testCompile 'org.testng:testng:6.8.7'
}
// Configure the oneJar task
task oneJar(type: OneJar) {
mainClass = mainClassName
additionalDir = file('src/main/resources') // adds log4j.properties to the combined jar
doLast {
// renaming ohcount4j-project.version-standalone.jar to ohcount4j-standalone.jar
file('build/libs/' + archivesBaseName + '-' +project.version + '-standalone.jar').renameTo(file('build/libs/ohcount4j-standalone.jar'))
}
}
build.doLast {
// execute oneJar
oneJar.execute()
}
task generateScanSources() {
String scannerPackage = 'com/blackducksoftware/ohcount4j/scan'
File scannerSrc = file('src/scanners/ragel')
File generatedJavaBase = file("src/generated/java")
File targetBase = file("$generatedJavaBase/$scannerPackage")
inputs.dir scannerSrc
outputs.dir generatedJavaBase
doLast {
targetBase.mkdirs()
scannerSrc.eachFile groovy.io.FileType.FILES, { sourceFile ->
String baseName = sourceFile.getName().replaceAll('\\.java\\.rl$', '.java')
String source = sourceFile.absolutePath
if (sourceFile.name.endsWith('.java.rl')) {
String target = new File(targetBase, baseName).absolutePath
def proc = "ragel -J -o $target $source".execute(null, scannerSrc)
proc.in.eachLine {line -> println line}
proc.err.eachLine {line -> println 'ERROR: ' + line}
proc.waitFor()
}
}
}
}
sourceSets {
generated
}
sourceSets.main.java.srcDirs += sourceSets.generated.java.srcDirs
compileJava.dependsOn generateScanSources
clean.dependsOn cleanGenerateScanSources
task sourcesJar(type:Jar){
from sourceSets.main.allSource
from sourceSets.generated.allSource
classifier = 'sources'
}
artifacts { archives sourcesJar }
test {
useTestNG()
}
publishing {
publications {
nebula(MavenPublication) {
from components.java
artifact sourcesJar {
classifier 'sources'
}
}
}
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
task wrapper(type: Wrapper) { gradleVersion = '2.14' }