-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
145 lines (115 loc) · 3.42 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
142
143
144
///////////////////////////////////////////////////////////////////////////////////////
//
// Gradle Template Summary
//
// Frequently Used Command:
// [ gradle ] Default task. same with 'gradle build'.
// [ gradle build ] Compile/test your code, and create a war file containing your main classes and resources.
//
////////////////////////////////////////////////////////////////////////////////////////
//Definition apply plugin
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
//--------------------------------- Based setting for current project ---------------------------------
// Definition sourceCompatibility and targetCompatibility.
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
buildscript {
ext {
MODULE = "snmp4jdemo"
MAVEN_GROUP_ID = "com.logicmonitor"
MAVEN_ARTIFACT_ID = "snmp4jdemo"
MAVEN_VERSION = "0.1"
}
repositories {
maven {
credentials {
username MAVEN_REPO_USERNAME
password MAVEN_REPO_PASSWORD
}
url REPOSITORRY_URL
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
// Access maven center.
repositories {
maven {
credentials {
username MAVEN_REPO_USERNAME
password MAVEN_REPO_PASSWORD
}
url REPOSITORRY_URL
}
}
// Definition source which should include.
sourceSets {
main {
java {
srcDir 'src'
}
resources {
}
}
}
//--------------------------------- Dependencies definition ---------------------------------
dependencies {
// https://mvnrepository.com/artifact/org.snmp4j/snmp4j
compile group: 'org.snmp4j', name: 'snmp4j', version: '2.5.6'
runtime(
)
}
// Define manifest
ext.sharedManifest = manifest {
attributes(
'Modlue': "${MODULE}",
'Implementation-Title': "${project.name}",
'Built-Date': new Date().getDateTimeString(),
'Built-With': "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}",
'Created-By': 'Java ' + System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')'
)
}
//--------------------------------- Specific Tasks ---------------------------------
/*
* Override jar task addition attributes
*/
jar {
manifest = project.manifest {
from sharedManifest
}
}
/**
* fatjar demo
*/
task fatjar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'snmp4jdemo',
'Implementation-Version': '1.0'
}
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}
defaultTasks 'clean','test','jar'
task build (overwrite: true ) {
dependsOn = ['clean','test','jar']
test.mustRunAfter clean
jar.mustRunAfter test
}
task devbuild {
dependsOn = ['clean','jar']
jar.mustRunAfter clean
}
//Define the test task
test {
ignoreFailures = true
reports.html.destination = file("$buildDir/test-reports")
}
task createJavaProject << {
sourceSets*.java.srcDirs*.each { it.mkdirs() }
sourceSets*.resources.srcDirs*.each { it.mkdirs()}
}