Skip to content

Commit 3da27f6

Browse files
committed
Added websocket, proxy, epoll as feature capabilities
Added pom publications for features Workaround for publishing gradle metadata to bintray
1 parent 8538b15 commit 3da27f6

File tree

2 files changed

+68
-12
lines changed

2 files changed

+68
-12
lines changed

Diff for: build.gradle

+67-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ buildscript {
88
}
99

1010
plugins {
11-
id 'nebula.optional-base' version '3.0.3'
1211
id 'com.github.johnrengelman.shadow' version '4.0.4' apply false
1312
id 'biz.aQute.bnd.builder' version '4.2.0' apply false
1413
id 'com.github.hierynomus.license' version '0.14.0' apply false
@@ -93,16 +92,30 @@ dependencies {
9392
implementation group: 'org.jetbrains', name: 'annotations', version: jetbrainsAnnotationsVersion
9493
implementation group: 'com.google.dagger', name: 'dagger', version: daggerVersion
9594

96-
implementation group: 'io.netty', name: 'netty-codec-http', version: nettyVersion, optional
97-
implementation group: 'io.netty', name: 'netty-handler-proxy', version: nettyVersion, optional
98-
implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: nettyVersion, classifier: 'linux-x86_64', optional
99-
10095
compileOnly group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
10196

10297
annotationProcessor group: 'com.google.dagger', name: 'dagger-compiler', version: daggerVersion
10398
}
10499

105100

101+
/* ******************** optional dependencies ******************** */
102+
103+
def features = ['websocket', 'proxy', 'epoll']
104+
java {
105+
features.each {
106+
registerFeature(it) {
107+
usingSourceSet(sourceSets.main)
108+
}
109+
}
110+
}
111+
112+
dependencies {
113+
websocketImplementation group: 'io.netty', name: 'netty-codec-http', version: nettyVersion
114+
proxyImplementation group: 'io.netty', name: 'netty-handler-proxy', version: nettyVersion
115+
epollImplementation group: 'io.netty', name: 'netty-transport-native-epoll', version: nettyVersion, classifier: 'linux-x86_64'
116+
}
117+
118+
106119
/* ******************** test ******************** */
107120

108121
allprojects {
@@ -246,11 +259,12 @@ allprojects {
246259
url = project.issuesUrl
247260
}
248261
}
249-
artifact javadocJar
250-
artifact sourcesJar
251262
}
252263
normal(MavenPublication) {
253-
from components.java
264+
from project.components.java
265+
artifact project.tasks.javadocJar
266+
artifact project.tasks.sourcesJar
267+
suppressAllPomMetadataWarnings()
254268
}
255269
}
256270
}
@@ -286,6 +300,19 @@ allprojects {
286300
}
287301
}
288302
}
303+
304+
// workaround for publishing gradle metadata https://github.com/bintray/gradle-bintray-plugin/issues/229
305+
//noinspection UnnecessaryQualifiedReference
306+
project.tasks.withType(com.jfrog.bintray.gradle.tasks.BintrayUploadTask) {
307+
doFirst {
308+
publishing.publications.withType(MavenPublication).each { publication ->
309+
def moduleFile = new File(new File(new File(project.buildDir, 'publications'), publication.name), 'module.json')
310+
if (moduleFile.exists()) {
311+
publication.artifact(moduleFile).setExtension('module')
312+
}
313+
}
314+
}
315+
}
289316
}
290317
}
291318

@@ -295,9 +322,11 @@ allprojects {
295322
publications {
296323
shaded(MavenPublication) {
297324
artifactId project.name + '-' + project.shadedAppendix
298-
artifact shadowJar
299-
pom.withXml { xml ->
300-
def dependenciesNode = xml.asNode().appendNode('dependencies')
325+
artifact project.tasks.shadowJar
326+
artifact project.tasks.javadocJar
327+
artifact project.tasks.sourcesJar
328+
pom.withXml {
329+
def dependenciesNode = asNode().appendNode('dependencies')
301330

302331
project.configurations.api.allDependencies.each {
303332
def dependencyNode = dependenciesNode.appendNode('dependency')
@@ -313,6 +342,33 @@ allprojects {
313342
}
314343
}
315344

345+
features.each { feature ->
346+
publishing {
347+
publications {
348+
create(feature, MavenPublication) {
349+
artifactId project.name + '-' + feature
350+
pom.withXml {
351+
def dependenciesNode = asNode().appendNode('dependencies')
352+
353+
def rootDependencyNode = dependenciesNode.appendNode('dependency')
354+
rootDependencyNode.appendNode('groupId', project.group)
355+
rootDependencyNode.appendNode('artifactId', project.name)
356+
rootDependencyNode.appendNode('version', project.version)
357+
rootDependencyNode.appendNode('scope', 'compile')
358+
359+
project.configurations.getByName(feature + 'Implementation').allDependencies.each {
360+
def dependencyNode = dependenciesNode.appendNode('dependency')
361+
dependencyNode.appendNode('groupId', it.group)
362+
dependencyNode.appendNode('artifactId', it.name)
363+
dependencyNode.appendNode('version', it.version)
364+
dependencyNode.appendNode('scope', 'runtime')
365+
}
366+
}
367+
}
368+
}
369+
}
370+
}
371+
316372
apply plugin: 'com.github.breadmoirai.github-release'
317373

318374
githubRelease {

Diff for: gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Wed Sep 25 23:53:09 CEST 2019
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)