Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3529939

Browse files
committed
Version not propogating to the bintray publish
- Adding publish version to the configured publications - Refactored the subprojects build Related to springfox#759
1 parent bd7b4c6 commit 3529939

8 files changed

Lines changed: 102 additions & 62 deletions

File tree

build.gradle

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,76 +20,77 @@ buildscript {
2020
}
2121
apply plugin: 'build-dashboard'
2222
apply plugin: 'project-report'
23+
apply plugin: "com.github.adrianbk.tcitrigger"
24+
apply plugin: 'springfox-multi-release'
2325

2426
ext {
2527
apiKey = System.getenv('GIT_HUB_API_KEY')
2628
jdkVersion = 1.6
2729
}
2830

29-
apply plugin: 'springfox-multi-release'
30-
31-
configure(ProjectDefinitions.publishable(project)) { subproject ->
31+
subprojects {
3232
apply plugin: "com.ofg.uptodate"
3333
//Not strictly groovy projects but useful for the IDE to recognise groovy test sources
3434
apply plugin: 'groovy' //gradle groovy plugin extends the java plugin
35+
apply plugin: 'com.github.adrianbk.jvmsrc'
36+
apply plugin: 'checkstyle'
37+
apply from: "$rootDir/gradle/coverage.gradle"
38+
//Commented PMD and Findbugs as its taking too much time for very little value
39+
//Perhaps run every 20 CI builds (mod of ci build number)
40+
// apply from: "$rootDir/gradle/code-quality.gradle"
41+
if (ProjectDefinitions.publishable(it)) {
42+
apply plugin: 'maven-publish'
43+
apply from: "$rootDir/gradle/publishing.gradle"
44+
apply from: "$rootDir/gradle/artifacts.gradle"
45+
apply from: "$rootDir/gradle/bintray_publish.gradle"
46+
}
47+
repositories {
48+
jcenter()
49+
}
3550

36-
test {
37-
maxParallelForks = 2
51+
checkstyle {
52+
configFile = file("$rootDir/config/checkstyle.xml")
3853
}
3954

40-
compileJava.options.encoding = 'UTF-8'
55+
checkstyleMain.source = "src/main/java"
4156

42-
sourceCompatibility = jdkVersion
43-
targetCompatibility = jdkVersion
57+
test {
58+
maxParallelForks = 2
59+
}
4460

4561
configurations {
4662
provided
4763
compile.extendsFrom provided
4864
}
4965

50-
group = 'io.springfox'
51-
52-
apply plugin: 'com.github.adrianbk.jvmsrc'
5366
jvmsrc {
5467
packageName "springfox"
5568
}
5669

70+
compileJava.options.encoding = 'UTF-8'
71+
72+
sourceCompatibility = jdkVersion
73+
targetCompatibility = jdkVersion
74+
group = 'io.springfox'
75+
version = project.version
76+
5777
jar {
5878
manifest {
5979
attributes(
60-
'Implementation-Title': "${project.name}",
61-
'Implementation-Version': version.toString(),
62-
'Created-By': System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')',
63-
'Built-With': "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}",
64-
'Build-Time': "${new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")}",
65-
'Built-By': System.getProperty('user.name'),
66-
'Built-On': "${InetAddress.localHost.hostName}/${InetAddress.localHost.hostAddress}"
80+
'Implementation-Title': "${project.name}",
81+
'Implementation-Version': version.toString(),
82+
'Created-By': System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')',
83+
'Built-With': "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}",
84+
'Build-Time': "${new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")}",
85+
'Built-By': System.getProperty('user.name'),
86+
'Built-On': "${InetAddress.localHost.hostName}/${InetAddress.localHost.hostAddress}"
6787
)
6888
}
6989
}
70-
71-
apply plugin: 'checkstyle'
72-
checkstyle {
73-
configFile = file("$rootDir/config/checkstyle.xml")
74-
}
75-
checkstyleMain.source = "src/main/java"
76-
77-
apply plugin: 'maven-publish'
78-
apply from: "$rootDir/gradle/publishing.gradle"
79-
apply from: "$rootDir/gradle/artifacts.gradle"
80-
apply from: "$rootDir/gradle/bintray_publish.gradle"
81-
apply from: "$rootDir/gradle/coverage.gradle"
82-
//Commented PMD and Findbugs as its taking too much time for very little value
83-
//Perhaps run every 20 CI builds (mod of ci build number)
84-
// apply from: "$rootDir/gradle/code-quality.gradle"
85-
86-
repositories {
87-
jcenter()
88-
}
89-
9090
}
9191

9292
apply plugin: "com.github.adrianbk.tcitrigger"
93+
apply from: "$rootDir/gradle/documentation.gradle"
9394

9495
tciTrigger {
9596
gitHubRepo 'adrianbk/swagger-springmvc-demo'
@@ -101,4 +102,3 @@ tciTrigger {
101102
}
102103
}
103104

104-
apply from: "$rootDir/gradle/documentation.gradle"

buildSrc/src/main/groovy/springfox/gradlebuild/plugins/MultiProjectReleasePlugin.groovy

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import org.gradle.api.Project
2424
import org.gradle.api.Task
2525
import org.gradle.api.logging.Logger
2626
import org.gradle.api.logging.Logging
27+
import org.gradle.api.publish.maven.tasks.PublishToMavenLocal
28+
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
2729
import springfox.gradlebuild.BintrayCredentials
2830
import springfox.gradlebuild.BuildInfo
2931
import springfox.gradlebuild.BuildInfoFactory
@@ -67,13 +69,13 @@ public class MultiProjectReleasePlugin implements Plugin<Project> {
6769
group = 'Help'
6870
description = 'Show project publishing information'
6971
}
70-
project.tasks.showPublishInfo << {
71-
LOG.info "================== Project version: $project.version, $versioningInfo"
72-
}
7372

7473
configureSnapshotTaskGraph(project)
7574
configureReleaseTaskGraph(project)
7675
configureVersionAndPublications(project, versioningInfo)
76+
project.tasks.showPublishInfo {
77+
LOG.info "================== Project version: $project.version, $versioningInfo"
78+
}
7779
}
7880

7981
def configureSnapshotTaskGraph(Project project) {
@@ -84,9 +86,9 @@ public class MultiProjectReleasePlugin implements Plugin<Project> {
8486
iSnapshotCheckTask.dependsOn javaCheckTasks
8587

8688
evaluatedProject.subprojects.each {
87-
def jcenterTasks = it.tasks.findAll { it.name.contains('ToJcenterRepository') }
88-
if (jcenterTasks) {
89-
snapshotTask.dependsOn jcenterTasks
89+
it.tasks.findAll { it.name.contains('ToJcenterRepository') }.each {
90+
it.publication.version = project.version
91+
snapshotTask.dependsOn it
9092
}
9193
}
9294
}
@@ -109,9 +111,11 @@ public class MultiProjectReleasePlugin implements Plugin<Project> {
109111
iCheckTask.dependsOn javaCheckTasks
110112

111113
evaluatedProject.subprojects.each {
112-
def bintrayPublishTask = it.tasks.findByPath('bintrayUpload')
113-
if (bintrayPublishTask) {
114-
iPublishTask.dependsOn(bintrayPublishTask)
114+
it.tasks.findByPath('bintrayUpload').each {
115+
it.with {
116+
versionName = project.version
117+
}
118+
iPublishTask.dependsOn(it)
115119
}
116120
}
117121
}
@@ -137,19 +141,22 @@ public class MultiProjectReleasePlugin implements Plugin<Project> {
137141
}
138142

139143
def configurePublications(Project project, BuildInfo buildInfo) {
140-
def type = buildInfo.isReleaseBuild ? 'snapshot' : 'release'
144+
def type = buildInfo.isReleaseBuild ? 'release' : 'snapshot'
141145
project.ext {
142146
bintrayCredentials = new BintrayCredentials(project)
143147
artifactRepoBase = 'http://oss.jfrog.org/artifactory'
144148
repoPrefix = 'oss'
145149
releaseRepos = {
150+
146151
//Only snapshots - bintray plugin takes care of non-snapshot releases
147-
maven {
148-
name 'jcenter'
149-
url "${artifactRepoBase}/${repoPrefix}-${type}-local"
150-
credentials {
151-
username = "${bintrayCredentials.username}"
152-
password = "${bintrayCredentials.password}"
152+
if (!buildInfo.isReleaseBuild) {
153+
maven {
154+
name 'jcenter'
155+
url "${artifactRepoBase}/${repoPrefix}-${type}-local"
156+
credentials {
157+
username = "${bintrayCredentials.username}"
158+
password = "${bintrayCredentials.password}"
159+
}
153160
}
154161
}
155162
}

buildSrc/src/main/groovy/springfox/gradlebuild/utils/ProjectDefinitions.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ package springfox.gradlebuild.utils
2525
import org.gradle.api.Project
2626

2727
class ProjectDefinitions {
28-
static publishable(Project project) {
28+
static publishables(Project project) {
2929
return project.subprojects.findAll {
3030
!['swagger-contract-tests', 'buildSrc', 'springfox-spring-config'].contains(it.name)
3131
}
3232
}
33+
static publishable(Project project) {
34+
!['swagger-contract-tests', 'buildSrc', 'springfox-spring-config'].contains(project.name)
35+
}
3336
}

gradle/bintray_publish.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ if (!isSnapshot()) {
6262
}
6363

6464
def isSnapshot() {
65-
String.valueOf(project.version).endsWith("-SNAPSHOT")
65+
def isSnapshot = project.gradle.startParameter.taskNames.contains("snapshot")
66+
println "================== Project: $project.name, isSnapshot: $isSnapshot"
6667
}

gradle/documentation.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def isSnapshot(project) {
6060
}
6161

6262
task allJavadoc(type: Javadoc) {
63-
final def publishable = ProjectDefinitions.publishable(project)
64-
source publishable.collect { it.sourceSets.main.allJava }
65-
classpath = files(publishable.collect { it.sourceSets.main.compileClasspath })
63+
final def publishables = ProjectDefinitions.publishables(project)
64+
source publishables.collect { it.sourceSets.main.allJava }
65+
classpath = files(publishables.collect { it.sourceSets.main.compileClasspath })
6666
destinationDir = file("${buildDir}/docs/javadoc")
6767
}
6868

gradle/publishing.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ext {
2-
relUsername = project.hasProperty('bintray_username') ? project.property('bintray_username') : 'admin'
3-
relPassword = project.hasProperty('bintray_password') ? project.property('bintray_password') : 'password'
2+
relUsername = project.hasProperty('bintrayUsername') ? project.property('bintrayUsername') : 'admin'
3+
relPassword = project.hasProperty('bintrayPassword') ? project.property('bintrayPassword') : 'password'
44

55
pomMetaData = {
66
resolveStrategy = Closure.DELEGATE_FIRST

springfox-spring-config/src/main/java/springfox/springconfig/Swagger2SpringBoot.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
*
3+
* Copyright 2015 the original author or authors.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*
18+
*/
19+
120
package springfox.springconfig;
221

322
import com.fasterxml.classmate.TypeResolver;

swagger-contract-tests/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ configurations {
2020
//Logback causing spring boot errors
2121
all*.exclude group: 'ch.qos.logback'
2222
}
23+
ext {
24+
limits = [
25+
'instruction': 89.5,
26+
'line' : 85,
27+
'complexity' : 80,
28+
'method' : 80,
29+
'branch' : 85,
30+
'class' : 94
31+
]
32+
}
2333

2434
dependencies {
2535
compile("org.springframework.boot:spring-boot-starter-web")

0 commit comments

Comments
 (0)