forked from Petersoj/alpaca-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
188 lines (156 loc) · 5.86 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/3.4.1/userguide/tutorial_java_projects.html
*/
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
// add additional dependencies here if you wish to reference instead of generate them (see example directory)
}
}
plugins {
id 'maven-publish'
id 'io.codearte.nexus-staging' version '0.11.0'
}
// Apply the java plugin to add support for Java
apply plugin: 'java'
// Apply the application plugin to add support for building an application
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'com.bmuschko.nexus'
archivesBaseName = 'alpaca-java'
group = 'io.github.mainstringargs'
version = '5.0.13-SNAPSHOT'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
maven { url "https://repo.maven.apache.org/maven2" }
jcenter()
//maven { url "http://mvnrepository.com/artifact" }
}
dependencies {
// This dependency is found on compile classpath of this component and consumers.
compile 'com.google.guava:guava:20.0'
compile "com.mashape.unirest:unirest-java:1.4.9"
compile "com.google.code.gson:gson:2.8.5"
compile "commons-lang:commons-lang:2.6"
compile 'org.apache.logging.log4j:log4j-api:2.11.1'
compile 'org.apache.logging.log4j:log4j-core:2.11.1'
compile "org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.28.v20200408"
// Use JUnit test framework
testCompile 'junit:junit:4.12'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
modifyPom {
project {
name 'alpaca-java'
description 'Java API for Alpaca trading'
url 'https://github.com/mainstringargs/alpaca-java'
inceptionYear '2018'
scm {
url 'https://github.com/mainstringargs/alpaca-java'
connection 'https://github.com/mainstringargs/alpaca-java.git'
developerConnection 'https://github.com/mainstringargs/alpaca-java.git'
}
licenses {
license {
name 'MIT License'
url 'https://opensource.org/licenses/MIT'
distribution 'repo'
}
}
developers {
developer {
id 'mainstringargs'
name 'main(String[] args)'
email '[email protected]'
}
}
}
}
// https://stackoverflow.com/questions/52205209/configure-gradle-build-to-suppress-javadoc-console-warnings
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
javadoc.options.addStringOption("charset", "UTF-8")
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}
extraArchive {
sources = true
tests = true
javadoc = true
}
nexus {
sign = true
repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
nexusStaging {
packageGroup = "io.github.mainstringargs" //optional if packageGroup == project.getGroup()
}
processResources {
exclude('alpaca.properties', 'polygon.properties')
}
sourceSets {
main {
java {
srcDir 'src/main/java'
srcDir 'build/generated-sources/schemajson'
}
}
}
// The generated POJOs will be in a package structure analogous to the path in the 'schema_json/' directory
// See: https://github.com/joelittlejohn/jsonschema2pojo/wiki/Reference
task generatePOJOs() {
final def targetDirectory = "${project.buildDir}" + File.separator + "generated-sources" + File.separator + "schemajson"
final def jsonSourceDirectory = "${project.projectDir}" + File.separator + "schema_json" + File.separator
final def jsonPackageNameStart = "io.github.mainstringargs.domain."
// Clear all generated sources
delete targetDirectory
// Loop through all files in schema JSON file tree
file(jsonSourceDirectory).eachFileRecurse { file ->
if (file.getName().endsWith(".json")) {
def startPackageIndex = file.getAbsolutePath().indexOf(jsonSourceDirectory) + jsonSourceDirectory.length()
def targetPackage = jsonPackageNameStart + file.getParentFile().getAbsolutePath()
.substring(startPackageIndex)
.replace(File.separator, '.').replace('-', '').replace('_', '')
.toLowerCase()
def jsonToPOJOTask = tasks.create('json2POJOTask-' + targetPackage + "." + file.getName(), GradleBuild) {
startParameter.projectProperties = ['source' : file.getAbsolutePath(),
'targetPackage' : targetPackage,
'targetDirectory': targetDirectory]
buildFile = 'schemaJson2Pojo.gradle'
tasks = ['generateJsonSchema2Pojo']
}
dependsOn jsonToPOJOTask
}
}
}
compileJava {
dependsOn generatePOJOs
}
build.finalizedBy(publishToMavenLocal)
if (hasProperty('buildScan')) {
buildScan { licenseAgreementUrl = 'https://gradle.com/terms-of-service'; licenseAgree = 'yes' }
}
startScripts {
classpath += files('resources')
}
//mainClassName = 'io.github.mainstringargs.alpaca.AlpacaExample'
mainClassName = 'io.github.mainstringargs.polygon.PolygonExample'