11plugins {
2- id ' cpp'
2+ id ' cpp'
33}
44
55description = ' RSocket RPC Protobuf Generator'
@@ -13,41 +13,41 @@ sourceCompatibility = 1.8
1313targetCompatibility = 1.8
1414
1515dependencies {
16- compileOnly ' io.projectreactor:reactor-core'
17- compileOnly ' com.google.protobuf:protobuf-java'
18- compileOnly ' javax.inject:javax.inject'
16+ compileOnly ' io.projectreactor:reactor-core'
17+ compileOnly ' com.google.protobuf:protobuf-java'
18+ compileOnly ' javax.inject:javax.inject'
1919}
2020
2121protobuf {
22- generatedFilesBaseDir = " ${ projectDir} /src/generated"
23-
24- protoc {
25- artifact = " com.google.protobuf:protoc"
26- }
27- plugins {
28- rsocketRpc {
29- path = pathToPlugin
30- }
31- }
32- generateProtoTasks {
33- all(). each { task ->
34- task. dependsOn ' :rsocket-rpc-protobuf:java_pluginExecutable'
35- task. inputs. file " $pathToPlugin "
36- task. inputs. file " ${ rootProject.projectDir} /build.gradle"
37- task. plugins {
38- rsocketRpc {}
39- }
40- }
41- }
22+ generatedFilesBaseDir = " ${ projectDir} /src/generated"
23+
24+ protoc {
25+ artifact = " com.google.protobuf:protoc"
26+ }
27+ plugins {
28+ rsocketRpc {
29+ path = pathToPlugin
30+ }
31+ }
32+ generateProtoTasks {
33+ all(). each { task ->
34+ task. dependsOn ' :rsocket-rpc-protobuf:java_pluginExecutable'
35+ task. inputs. file " $pathToPlugin "
36+ task. inputs. file " ${ rootProject.projectDir} /build.gradle"
37+ task. plugins {
38+ rsocketRpc {}
39+ }
40+ }
41+ }
4242}
4343
4444// Adds space-delimited arguments from the environment variable env to the
4545// argList.
4646def addEnvArgs = { env , argList ->
47- def value = System . getenv(env)
48- if (value != null ) {
49- value. split(' +' ). each() { it -> argList. add(it) }
50- }
47+ def value = System . getenv(env)
48+ if (value != null ) {
49+ value. split(' +' ). each() { it -> argList. add(it) }
50+ }
5151}
5252
5353// Adds corresponding "-l" option to the argList if libName is not found in
@@ -56,136 +56,182 @@ def addEnvArgs = { env, argList ->
5656// order to get statically linked, otherwise we add the libraries through "-l"
5757// so that they can be searched for in default search paths.
5858def addLibraryIfNotLinked = { libName , argList ->
59- def ldflags = System . env. LDFLAGS
60- if (ldflags == null || ! ldflags. contains(' lib' + libName + ' .a' )) {
61- argList. add(' -l' + libName)
62- }
59+ def ldflags = System . env. LDFLAGS
60+ if (ldflags == null || ! ldflags. contains(' lib' + libName + ' .a' )) {
61+ argList. add(' -l' + libName)
62+ }
6363}
6464
65- String arch = rootProject. hasProperty(' targetArch' ) ? rootProject. targetArch : osdetector. arch
65+ String arch = rootProject. hasProperty(' targetArch' ) ? rootProject. targetArch :
66+ osdetector. arch
6667boolean vcDisable = rootProject. hasProperty(' vcDisable' ) ? rootProject. vcDisable : false
6768
6869model {
69- toolChains {
70- // If you have both VC and Gcc installed, VC will be selected, unless you
71- // set 'vcDisable=true'
72- if (! vcDisable) {
73- println ' using visualCpp'
74- visualCpp(VisualCpp ) {
75- }
76- }
77- gcc(Gcc ) {
78- target(" ppcle_64" )
79- }
80- clang(Clang ) {
81- }
82- }
83-
84- platforms {
85- x86_32 {
86- architecture " x86"
87- }
88- x86_64 {
89- architecture " x86_64"
90- }
91- ppcle_64 {
92- architecture " ppcle_64"
93- }
94- }
95-
96- components {
97- java_plugin(NativeExecutableSpec ) {
98- if (arch in [' x86_32' , ' x86_64' , ' ppcle_64' ]) {
99- // If arch is not within the defined platforms, we do not specify the
100- // targetPlatform so that Gradle will choose what is appropriate.
101- targetPlatform arch
102- }
103- baseName " $pluginPrefix "
104- }
105- }
106-
107- binaries {
108- all {
109- if (toolChain in Gcc || toolChain in Clang ) {
110- cppCompiler. define(" RSOCKET_RPC_VERSION" , version)
111- cppCompiler. args " --std=c++0x"
112- addEnvArgs(" CXXFLAGS" , cppCompiler. args)
113- addEnvArgs(" CPPFLAGS" , cppCompiler. args)
114- if (osdetector. os == " osx" ) {
115- cppCompiler. args " -mmacosx-version-min=10.7" , " -stdlib=libc++"
116- addLibraryIfNotLinked(' protoc' , linker. args)
117- addLibraryIfNotLinked(' protobuf' , linker. args)
118- } else if (osdetector. os == " windows" ) {
119- linker. args " -static" , " -lprotoc" , " -lprotobuf" , " -static-libgcc" , " -static-libstdc++" ,
120- " -s"
121- } else {
122- // Link protoc, protobuf, libgcc and libstdc++ statically.
123- // Link other (system) libraries dynamically.
124- // Clang under OSX doesn't support these options.
125- linker. args " -Wl,-Bstatic" , " -lprotoc" , " -lprotobuf" , " -static-libgcc" ,
126- " -static-libstdc++" ,
127- " -Wl,-Bdynamic" , " -lpthread" , " -s"
128- }
129- addEnvArgs(" LDFLAGS" , linker. args)
130- } else if (toolChain in VisualCpp ) {
131- cppCompiler. define(" RSOCKET_RPC_VERSION" , version)
132- cppCompiler. args " /EHsc" , " /MT"
133- if (rootProject. hasProperty(' vcProtobufInclude' )) {
134- cppCompiler. args " /I${ rootProject.vcProtobufInclude} "
135- } else {
136- println ' You may need to add a propertry, vcProtobufInclude, pointing to protobuf include'
137- }
138-
139- if (rootProject. hasProperty(' vcProtobufLibs' )) {
140- linker. args " /LIBPATH:${ rootProject.vcProtobufLibs} "
141- } else {
142- println ' You may need to add a propertry, vcProtobufLibs, pointing to protobuf lib'
143- }
144-
145- linker. args " libprotobuf.lib" , " libprotoc.lib"
146- }
147- }
148- }
70+ toolChains {
71+ // If you have both VC and Gcc installed, VC will be selected, unless you
72+ // set 'vcDisable=true'
73+ if (! vcDisable) {
74+ println ' using visualCpp'
75+ visualCpp(VisualCpp ) {}
76+ }
77+ gcc(Gcc ) {
78+ target(" ppcle_64" )
79+ }
80+ clang(Clang ) {}
81+ }
82+
83+ platforms {
84+ x86_32 {
85+ architecture " x86"
86+ }
87+ x86_64 {
88+ architecture " x86_64"
89+ }
90+ ppcle_64 {
91+ architecture " ppcle_64"
92+ }
93+ }
94+
95+ components {
96+ java_plugin(NativeExecutableSpec ) {
97+ if (arch in [' x86_32' , ' x86_64' , ' ppcle_64' ]) {
98+ // If arch is not within the defined platforms, we do not specify the
99+ // targetPlatform so that Gradle will choose what is appropriate.
100+ targetPlatform arch
101+ }
102+ baseName " $pluginPrefix "
103+ }
104+ }
105+
106+ binaries {
107+ all {
108+ if (toolChain in Gcc || toolChain in Clang ) {
109+ cppCompiler. define(" RSOCKET_RPC_VERSION" , version)
110+ cppCompiler. args " --std=c++0x"
111+ addEnvArgs(" CXXFLAGS" , cppCompiler. args)
112+ addEnvArgs(" CPPFLAGS" , cppCompiler. args)
113+ if (osdetector. os == " osx" ) {
114+ cppCompiler. args " -mmacosx-version-min=10.7" , " -stdlib=libc++"
115+ addLibraryIfNotLinked(' protoc' , linker. args)
116+ addLibraryIfNotLinked(' protobuf' , linker. args)
117+ }
118+ else if (osdetector. os == " windows" ) {
119+ linker. args " -static" , " -lprotoc" , " -lprotobuf" , " -static-libgcc" ,
120+ " -static-libstdc++" ,
121+ " -s"
122+ }
123+ else {
124+ // Link protoc, protobuf, libgcc and libstdc++ statically.
125+ // Link other (system) libraries dynamically.
126+ // Clang under OSX doesn't support these options.
127+ linker. args " -Wl,-Bstatic" , " -lprotoc" , " -lprotobuf" , " -static-libgcc" ,
128+ " -static-libstdc++" ,
129+ " -Wl,-Bdynamic" , " -lpthread" , " -s"
130+ }
131+ addEnvArgs(" LDFLAGS" , linker. args)
132+ }
133+ else if (toolChain in VisualCpp ) {
134+ cppCompiler. define(" RSOCKET_RPC_VERSION" , version)
135+ cppCompiler. args " /EHsc" , " /MT"
136+ if (rootProject. hasProperty(' vcProtobufInclude' )) {
137+ cppCompiler. args " /I${ rootProject.vcProtobufInclude} "
138+ }
139+ else {
140+ println ' You may need to add a propertry, vcProtobufInclude, pointing to protobuf include'
141+ }
142+
143+ if (rootProject. hasProperty(' vcProtobufLibs' )) {
144+ linker. args " /LIBPATH:${ rootProject.vcProtobufLibs} "
145+ }
146+ else {
147+ println ' You may need to add a propertry, vcProtobufLibs, pointing to protobuf lib'
148+ }
149+
150+ linker. args " libprotobuf.lib" , " libprotoc.lib"
151+ }
152+ }
153+ }
149154}
150155
151156task buildArtifacts (type : Copy ) {
152- println ' generating artifacts'
153- dependsOn ' java_pluginExecutable'
154- from(" $buildDir /exe/java_plugin" ) {
155- if (osdetector. os != ' windows' ) {
156- rename pluginPrefix, ' $0.exe'
157- }
158- }
159- into artifactStagingPath
157+ println ' generating artifacts'
158+ dependsOn ' java_pluginExecutable'
159+ from(" $buildDir /exe/java_plugin" ) {
160+ if (osdetector. os != ' windows' ) {
161+ rename pluginPrefix, ' $0.exe'
162+ }
163+ }
164+ into artifactStagingPath
160165}
161166
162167compileJava. dependsOn ' :rsocket-rpc-protobuf:buildArtifacts'
163168compileJava. dependsOn ' :rsocket-rpc-protobuf:generateProto'
164169
165170clean {
166- delete protobuf. generatedFilesBaseDir
171+ delete protobuf. generatedFilesBaseDir
167172}
168173
169174artifacts {
170- archives(" $pathToPlugin " as File ) {
171- classifier osdetector. os + " -" + osdetector. arch
172- type " exe"
173- extension " exe"
174- builtBy buildArtifacts
175- }
175+ archives(" $pathToPlugin " as File ) {
176+ classifier osdetector. os + " -" + osdetector. arch
177+ type " exe"
178+ extension " exe"
179+ builtBy buildArtifacts
180+ }
176181}
177182
178183plugins. withType(MavenPublishPlugin ) {
179- publishing {
180- publications {
181- maven(MavenPublication ) {
182- groupId project. group
183-
184- artifact(pathToPlugin) {
185- classifier osdetector. os + " -" + osdetector. arch
186- builtBy buildArtifacts
187- }
188- }
189- }
190- }
184+ publishing {
185+ publications {
186+ maven(MavenPublication ) {
187+ groupId project. group
188+
189+ artifact(pathToPlugin) {
190+ classifier osdetector. os + " -" + osdetector. arch
191+ builtBy buildArtifacts
192+ }
193+
194+ pom. withXml {
195+ asNode(). ' :version' + {
196+ resolveStrategy = DELEGATE_FIRST
197+
198+ name project. name
199+ description project. description
200+ url ' http://rsocket.io'
201+
202+ licenses {
203+ license {
204+ name ' The Apache Software License, Version 2.0'
205+ url ' http://www.apache.org/license/LICENSE-2.0.txt'
206+ }
207+ }
208+
209+ developers {
210+ developer {
211+ id ' robertroeser'
212+ name ' Robert Roeser'
213+ email ' robert@netifi.com'
214+ }
215+ developer {
216+ id ' rdegnan'
217+ name ' Ryland Degnan'
218+ email ' ryland@netifi.com'
219+ }
220+ developer {
221+ id ' OlegDokuka'
222+ name ' Oleh Dokuka'
223+ email ' oleh@netifi.com'
224+ }
225+ }
226+
227+ scm {
228+ connection ' scm:git:https://github.com/rsocket/rsocket-rpc-java.git'
229+ developerConnection ' scm:git:https://github.com/rsocket/rsocket-rpc-java.git'
230+ url ' https://github.com/rsocket/rsocket-rpc-java'
231+ }
232+ }
233+ }
234+ }
235+ }
236+ }
191237}
0 commit comments