This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
155 lines (127 loc) · 4.11 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
145
146
147
148
149
150
151
152
153
154
155
plugins {
id "org.sonarqube" version "2.6.2"
id "com.moowork.node" version "1.2.0"
id "org.ajoberstar.grgit" version "2.2.0"
id "org.springframework.boot" version "1.5.8.RELEASE"
id "com.palantir.docker" version "0.20.1"
}
// Output result file type definition
//- use 'java' value to create a JAR file
//- use 'war' value to create a deployable WAR file
apply plugin: 'java'
def targetJavaVersion = JavaVersion.VERSION_1_8;
sourceCompatibility = "${targetJavaVersion}"
targetCompatibility = "${targetJavaVersion}"
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'
apply plugin: 'com.palantir.docker-run'
apply plugin: 'idea'
apply plugin: 'eclipse'
group = 'org.sitmun'
version = "${sitmun_version}"
repositories {
mavenLocal()
mavenCentral()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/sitmun/sitmun-backend-core")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_API_KEY")
}
}
}
dependencies {
compile "io.springfox:springfox-data-rest:${springfox_swagger_version}"
compile "io.springfox:springfox-swagger2:${springfox_swagger_version}"
compile "io.springfox:springfox-swagger-ui:${springfox_swagger_version}"
compile ("org.sitmun:sitmun-backend-core:0.7+")
if (project.hasProperty('oracle')) {
compile "com.zaxxer:HikariCP:${hikaricp_version}"
compile "com.oracle:ojdbc7:${ojdbc7_version}"
} else if (project.hasProperty('postgresql')) {
compile "com.zaxxer:HikariCP:${hikaricp_version}"
compile "org.postgresql:postgresql:${postgresql_version}"
} else {
compile 'com.h2database:h2'
compile 'org.springframework.boot:spring-boot-devtools'
}
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2'
}
def profiles = 'h2'
bootRun {
if (project.hasProperty('h2')) {
profiles = 'h2'
} else if (project.hasProperty('oracle')) {
profiles = 'oracle'
} else if (project.hasProperty('postgresql')) {
profiles = 'postgresql'
}
args = ["--spring.profiles.active=" + profiles]
}
sourceSets {
main {
resources {
srcDirs = ["$projectDir/dist", "$projectDir/src/main/resources"]
}
}
}
task checkJavaVersion {
if (!JavaVersion.current().equals(targetJavaVersion)) {
String message = """
ERROR: Java ${targetJavaVersion} JDK required but ${JavaVersion.current()} found.
SOLUTION:
a) Point JAVA_HOME to a ${targetJavaVersion} JDK and then run gradle, or
b) Run ./gradlew -Dorg.gradle.java.home=/path_to_jdk_${targetJavaVersion}_directory"""
throw new GradleException(message)
}
}
compileJava.dependsOn checkJavaVersion
publishing {
publications {
mavenJava(MavenPublication) {
groupId group
artifactId 'sitmun-admin-app'
version version
from components.java
}
}
}
sonarqube {
properties {
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.organization', 'sitmun'
properties['sonar.sources'] += 'src/main/angular'
}
}
task buildApp(dependsOn: npmInstall) {
doLast {
def build = tasks.create(name: "buildAppToo", type: NpmTask)
build.args = ['run-script', 'build']
build.execute()
}
}
processResources.dependsOn buildApp
processResources.mustRunAfter buildApp
task install(dependsOn: publishToMavenLocal)
clean {
delete "node_modules"
delete "dist"
delete "database"
}
docker {
def projectJar = "${project.name}-${project.version}.jar"
dockerfile file("src/main/docker/Dockerfile")
name "${project.group}/${project.name}:${project.version}".toLowerCase()
copySpec.from("${buildDir}/libs/").into(".")
buildArgs(['JAR_FILE': projectJar])
}
dockerRun {
name project.name
image "${project.group}/${project.name}:${project.version}".toLowerCase()
clean false
ports '8080:8080'
}