This repository was archived by the owner on Feb 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathbuild.gradle
107 lines (94 loc) · 3.33 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
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
// VFS and httpclient to download with http/https
classpath deps.tools.vfs
classpath deps.tools.httpclient
classpath deps.tools.swaggerPlugin
}
}
apply plugin: 'org.ysb33r.vfs'
apply plugin: 'org.hidetake.swagger.generator'
apply plugin: 'idea'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply from: rootProject.file('gradle/convention.gradle')
apply from: rootProject.file('gradle/publish-jar.gradle')
repositories {
jcenter()
}
dependencies {
swaggerCodegen deps.swagger.v2.cli
compile deps.swagger.v2.annotations
compile deps.logging.slf4j
compile deps.serialize.jackson.databind
compile deps.bouncycastle.bcpkix
compile deps.httpsig.api
compile deps.httpsig.sshJce
compile deps.httpsig.sshBc
compile deps.guava
implementation deps.tools.httpclient
testCompile deps.test.guavaTestlib
testImplementation deps.test.spockCore
testImplementation deps.test.mockito
testRuntime deps.test.cglibNodep
testRuntime deps.test.objenesis
}
def spec = file("${project.getProjectDir()}/resources/smartapps-v1.yml")
def swaggerConfig = file("${project.getProjectDir()}/resources/config.json")
def swaggerOutput = file("${project.getBuildDir().path}/gen")
// Define Java code generation tasks
// For models-only generation, use 'jersey2' as it has no default serializer
swaggerSources {
smartapp {
inputFile = spec
code {
language = 'java'
library = 'jersey2'
configFile = swaggerConfig
outputDir = swaggerOutput
components = ['models']
additionalProperties = ['modelsOnly': 'true']
dependsOn validation
}
}
}
/**
* If the smartapps Swagger specification doesn't exist, download the latest.
*
* You have an opportunity to insert your own spec here if you are confident
* that you need something different than provided. Be warned, this is unsupported
* and may produce poor or incorrect results.
*/
task downloadSpecYml {
doLast {
vfs {
mkdir "${project.getProjectDir()}/resources"
if (!spec.exists()) {
cp 'https://smartthings.developer.samsung.com/docs/api-ref/resources/smartapps-v1.yml', spec
}
}
}
}
// Disallow CheckStyle from analyzing generated classes by setting
// the source to the non-generated directories
checkstyleMain.source = "${project.getProjectDir()}/src/main/java"
// Prior to generating classes, download the latest public spec if necessary
generateSwaggerCode.dependsOn downloadSpecYml
// Insert generated code into the sourceSets
sourceSets.main.java.srcDir "${swaggerSources.smartapp.code.outputDir}/src/main/java"
sourceSets.main.resources.srcDir "${swaggerSources.smartapp.code.outputDir}/src/main/resources"
// Generate classes prior to compileJava
compileJava.dependsOn swaggerSources.smartapp.code
// Automatically generate models when IntelliJ loads the project
ideaModule.dependsOn generateSwaggerCode
task githubJavadoc(type: Javadoc, dependsOn: generateSwaggerCode) {
source = sourceSets.main.allJava
destinationDir = rootProject.file('docs/smartapp-core/javadoc')
options.addBooleanOption("notimestamp", true)
}