|  | 
|  | 1 | +/* | 
|  | 2 | + * Copyright 2015 Real Logic Ltd. | 
|  | 3 | + * | 
|  | 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | + * you may not use this file except in compliance with the License. | 
|  | 6 | + * You may obtain a copy of the License at | 
|  | 7 | + * | 
|  | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | + * | 
|  | 10 | + * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | + * See the License for the specific language governing permissions and | 
|  | 14 | + * limitations under the License. | 
|  | 15 | + */ | 
|  | 16 | +apply plugin: 'java' | 
|  | 17 | +apply plugin: 'maven' | 
|  | 18 | +apply plugin: 'signing' | 
|  | 19 | +apply plugin: 'checkstyle' | 
|  | 20 | +apply plugin: 'eclipse' | 
|  | 21 | + | 
|  | 22 | +defaultTasks 'clean', 'build', 'install' | 
|  | 23 | + | 
|  | 24 | +group = 'uk.co.real-logic' | 
|  | 25 | +version = '1.0.4-RC2-SNAPSHOT' | 
|  | 26 | + | 
|  | 27 | +ext { | 
|  | 28 | + if (!project.hasProperty('ossrhUsername')) | 
|  | 29 | + ossrhUsername = '' | 
|  | 30 | + | 
|  | 31 | + if (!project.hasProperty('ossrhPassword')) | 
|  | 32 | + ossrhPassword = '' | 
|  | 33 | +} | 
|  | 34 | + | 
|  | 35 | +repositories { | 
|  | 36 | + mavenCentral() | 
|  | 37 | +} | 
|  | 38 | + | 
|  | 39 | +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' | 
|  | 40 | + | 
|  | 41 | +def generatedDir = "${project.buildDir}/generated" | 
|  | 42 | + | 
|  | 43 | +sourceSets { | 
|  | 44 | + main { | 
|  | 45 | + java { | 
|  | 46 | + srcDir 'main/java' | 
|  | 47 | + } | 
|  | 48 | + resources { | 
|  | 49 | + srcDir 'main/resources' | 
|  | 50 | + } | 
|  | 51 | + } | 
|  | 52 | + | 
|  | 53 | + test { | 
|  | 54 | + java { | 
|  | 55 | + srcDir 'test/java' | 
|  | 56 | + } | 
|  | 57 | + resources { | 
|  | 58 | + srcDir 'test/resources' | 
|  | 59 | + } | 
|  | 60 | + } | 
|  | 61 | + | 
|  | 62 | + generated.java.srcDir generatedDir | 
|  | 63 | + | 
|  | 64 | + examples.java.srcDir 'examples/java' | 
|  | 65 | +} | 
|  | 66 | + | 
|  | 67 | +dependencies { | 
|  | 68 | + testCompile 'org.hamcrest:hamcrest-all:1.3', | 
|  | 69 | + 'junit:junit:4.11', | 
|  | 70 | + 'org.mockito:mockito-all:1.9.5', | 
|  | 71 | + 'com.google.code.gson:gson:2.3.1' | 
|  | 72 | +} | 
|  | 73 | + | 
|  | 74 | +sourceCompatibility = 1.7 | 
|  | 75 | +targetCompatibility = 1.7 | 
|  | 76 | + | 
|  | 77 | +tasks.withType(JavaCompile) { | 
|  | 78 | + // Suppress warnings about using Unsafe and sun.misc | 
|  | 79 | + options.compilerArgs << '-XDignore.symbol.file' << '-Xlint:unchecked' | 
|  | 80 | + options.debug = true | 
|  | 81 | + options.fork = true | 
|  | 82 | + options.forkOptions.executable = 'javac' | 
|  | 83 | + options.warnings = false | 
|  | 84 | +} | 
|  | 85 | + | 
|  | 86 | +compileGeneratedJava.dependsOn 'generateExampleCodecs' | 
|  | 87 | +compileExamplesJava.dependsOn 'compileGeneratedJava' | 
|  | 88 | +compileGeneratedJava.classpath += sourceSets.main.runtimeClasspath | 
|  | 89 | +compileExamplesJava.classpath += sourceSets.generated.runtimeClasspath + sourceSets.main.runtimeClasspath | 
|  | 90 | + | 
|  | 91 | +task (generateExampleCodecs, dependsOn: 'test', type: JavaExec) { | 
|  | 92 | + main = 'uk.co.real_logic.sbe.SbeTool' | 
|  | 93 | + classpath = sourceSets.main.runtimeClasspath | 
|  | 94 | + systemProperties('sbe.output.dir': generatedDir, | 
|  | 95 | + 'sbe.target.language': 'Java', | 
|  | 96 | + 'sbe.validation.stop.on.error': 'true', | 
|  | 97 | + 'sbe.validation.xsd': 'main/resources/fpl/SimpleBinary1-0.xsd') | 
|  | 98 | + args 'examples/resources/example-schema.xml', 'examples/resources/example-extension-schema.xml' | 
|  | 99 | +} | 
|  | 100 | + | 
|  | 101 | +task (runExampleUsingGeneratedStub, dependsOn: 'compileExamplesJava', type: JavaExec) { | 
|  | 102 | + classpath = sourceSets.examples.runtimeClasspath + compileExamplesJava.classpath | 
|  | 103 | + main = 'uk.co.real_logic.sbe.examples.ExampleUsingGeneratedStub' | 
|  | 104 | +} | 
|  | 105 | + | 
|  | 106 | +task (runExampleUsingGeneratedStubExtension, dependsOn: 'compileExamplesJava', type: JavaExec) { | 
|  | 107 | + classpath = sourceSets.examples.runtimeClasspath + compileExamplesJava.classpath | 
|  | 108 | + main = 'uk.co.real_logic.sbe.examples.ExampleUsingGeneratedStubExtension' | 
|  | 109 | +} | 
|  | 110 | + | 
|  | 111 | +task (runOtfExample, dependsOn: 'compileExamplesJava', type: JavaExec) { | 
|  | 112 | + classpath = sourceSets.examples.runtimeClasspath + compileExamplesJava.classpath | 
|  | 113 | + main = 'uk.co.real_logic.sbe.examples.OtfExample' | 
|  | 114 | +} | 
|  | 115 | + | 
|  | 116 | +task runJavaExamples { | 
|  | 117 | + description 'Run Java Examples' | 
|  | 118 | + dependsOn 'runExampleUsingGeneratedStub', 'runExampleUsingGeneratedStubExtension', 'runOtfExample' | 
|  | 119 | +} | 
|  | 120 | + | 
|  | 121 | +checkstyle { | 
|  | 122 | + configFile = new File(rootDir, 'config/checkstyle.xml') | 
|  | 123 | + toolVersion = 5.9 | 
|  | 124 | +} | 
|  | 125 | + | 
|  | 126 | +javadoc { | 
|  | 127 | + title = '<h1>Simple Binary Encoding</h1>' | 
|  | 128 | + | 
|  | 129 | + options.bottom = '<i>Copyright © 2014-2015 Real Logic Ltd. All Rights Reserved.</i>' | 
|  | 130 | + options.addStringOption('XDignore.symbol.file', '-quiet') | 
|  | 131 | +} | 
|  | 132 | + | 
|  | 133 | +jar { | 
|  | 134 | + manifest.attributes('Main-Class': 'uk.co.real_logic.sbe.SbeTool') | 
|  | 135 | +} | 
|  | 136 | + | 
|  | 137 | +task sourcesJar(type: Jar) { | 
|  | 138 | + classifier = 'sources' | 
|  | 139 | + from sourceSets.main.allSource | 
|  | 140 | +} | 
|  | 141 | + | 
|  | 142 | +task javadocJar(type: Jar, dependsOn: javadoc) { | 
|  | 143 | + classifier = 'javadoc' | 
|  | 144 | + from javadoc.destinationDir | 
|  | 145 | +} | 
|  | 146 | + | 
|  | 147 | +signing { | 
|  | 148 | + sign configurations.archives | 
|  | 149 | +} | 
|  | 150 | + | 
|  | 151 | +artifacts { | 
|  | 152 | + archives sourcesJar, javadocJar | 
|  | 153 | +} | 
|  | 154 | + | 
|  | 155 | +uploadArchives { | 
|  | 156 | + repositories { | 
|  | 157 | + mavenDeployer { | 
|  | 158 | + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | 
|  | 159 | + | 
|  | 160 | + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { | 
|  | 161 | + authentication(userName: ossrhUsername, password: ossrhPassword) | 
|  | 162 | + } | 
|  | 163 | + | 
|  | 164 | + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { | 
|  | 165 | + authentication(userName: ossrhUsername, password: ossrhPassword) | 
|  | 166 | + } | 
|  | 167 | + | 
|  | 168 | + pom.project { | 
|  | 169 | + name = 'sbe' | 
|  | 170 | + packaging = 'jar' | 
|  | 171 | + // optionally artifactId can be defined here | 
|  | 172 | + description = 'FIX/SBE - OSI layer 6 presentation for encoding and decoding application messages in binary format for low-latency applications' | 
|  | 173 | + url = 'https://github.com/real-logic/simple-binary-encoding' | 
|  | 174 | + | 
|  | 175 | + scm { | 
|  | 176 | + connection = 'scm:git:github.com/real-logic/simple-binary-encoding.git' | 
|  | 177 | + developerConnection = 'scm:git:github.com/real-logic/simple-binary-encoding.git' | 
|  | 178 | + url = 'github.com/real-logic/simple-binary-encoding.git' | 
|  | 179 | + } | 
|  | 180 | + | 
|  | 181 | + licenses { | 
|  | 182 | + license { | 
|  | 183 | + name = 'The Apache License, Version 2.0' | 
|  | 184 | + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | 
|  | 185 | + } | 
|  | 186 | + } | 
|  | 187 | + | 
|  | 188 | + developers { | 
|  | 189 | + developer { | 
|  | 190 | + id = 'tmontgomery' | 
|  | 191 | + name = 'Todd L. Montgomery' | 
|  | 192 | + email = 'tmont@nard.net' | 
|  | 193 | + url = 'https://github.com/tmontgomery' | 
|  | 194 | + } | 
|  | 195 | + developer { | 
|  | 196 | + id = 'mjpt777' | 
|  | 197 | + name = 'Martin Thompson' | 
|  | 198 | + email = 'mjpt777@gmail.com' | 
|  | 199 | + url = 'https://github.com/mjpt777' | 
|  | 200 | + } | 
|  | 201 | + developer { | 
|  | 202 | + id = 'odeheurles' | 
|  | 203 | + name = 'Olivier Deheurles' | 
|  | 204 | + email = 'olivier@weareadaptive.com' | 
|  | 205 | + url = 'https://github.com/odeheurles' | 
|  | 206 | + } | 
|  | 207 | + } | 
|  | 208 | + } | 
|  | 209 | + } | 
|  | 210 | + } | 
|  | 211 | +} | 
|  | 212 | + | 
|  | 213 | +task wrapper(type: Wrapper) { | 
|  | 214 | + gradleVersion = '2.2' | 
|  | 215 | +} | 
0 commit comments