Skip to content

Commit 62a126d

Browse files
Jayatijdigger
authored andcommitted
Restructuring Gradle build
Created a single module and broke the build logic into smaller files Fixes GH-14
1 parent df55a71 commit 62a126d

File tree

131 files changed

+310
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+310
-249
lines changed

build.gradle

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ buildscript {
1818
}
1919
}
2020

21+
plugins {
22+
id "com.jfrog.bintray" version "1.3.1"
23+
}
2124

22-
allprojects {
2325
apply plugin: 'idea'
2426
apply plugin: 'eclipse'
2527
apply plugin: 'maven'
@@ -41,14 +43,12 @@ allprojects {
4143
// without running afoul of licensing restrictions
4244
flatDir { dirs rootProject.projectDir }
4345
}
44-
}
4546

4647
ext.vendor = 'Time Warner Cable - Converged Technology Group - CMS Team'
4748
ext.organization = "Time Warner Cable"
4849
ext.providerUrl = "https://www.timewarnercable.com"
4950
ext.providerLink = "https://github.com/TWCable/grabbit"
5051

51-
configure(excludeProjects()) {
5252
apply plugin: 'groovy'
5353
apply from: "${rootProject.projectDir}/gradle/dependencies.gradle"
5454
apply from: "${rootProject.projectDir}/testutils/gradle/testing.gradle"
@@ -60,10 +60,8 @@ configure(excludeProjects()) {
6060
attributes 'Implementation-Version': project.version
6161
attributes 'Implementation-Vendor': project.vendor
6262
}
63-
}
6463

65-
subprojects {
66-
afterEvaluate { project ->
64+
afterEvaluate {
6765
if (project.hasProperty('sourceCompatibility')) {
6866
project.sourceCompatibility = 1.7
6967
}
@@ -92,11 +90,6 @@ subprojects {
9290
}
9391
}
9492
}
95-
}
96-
97-
def excludeProjects() {
98-
subprojects.findAll { project -> (project.name != 'proto' && project.name != 'osgi-wrappers')}
99-
}
10093

10194
idea.project.ipr {
10295
withXml { provider ->
@@ -161,3 +154,67 @@ idea.project.ipr {
161154
}
162155
}
163156
}
157+
158+
apply from: "${rootProject.projectDir}/gradle/verifyComponentConfig.gradle"
159+
apply from: "${rootProject.projectDir}/gradle/utils.gradle"
160+
161+
apply plugin: 'osgi'
162+
apply plugin: 'scr'
163+
apply plugin: 'sling-bundle'
164+
apply plugin: 'protobuf'
165+
166+
// remove "mvn install" since it's not needed and causes a conflict
167+
def installTask = tasks.findByPath('install')
168+
if (installTask != null) tasks.remove(installTask)
169+
170+
apply from: "${rootProject.projectDir}/gradle/bundle.gradle"
171+
apply from: "${rootProject.projectDir}/gradle/packageExclusions.gradle"
172+
apply from: "${rootProject.projectDir}/gradle/idea.gradle"
173+
174+
gradle.taskGraph.whenReady { taskGraph ->
175+
if (taskGraph.hasTask(bintrayUpload)) {
176+
if (!project.hasProperty('bintray.user') || !project.hasProperty('bintray.key')) {
177+
throw new IllegalArgumentException((String)"Please define 'bintray.user' and " +
178+
"'bintray.key' properties. (Such as in ~/.gradle/gradle.properties)")
179+
}
180+
}
181+
}
182+
183+
version = new com.twcable.grabbit.Version(version as String)
184+
185+
bintray {
186+
user = project.properties['bintray.user']
187+
key = project.properties['bintray.key']
188+
filesSpec {
189+
from tasks.getByPath('createPackage').archivePath
190+
into '.'
191+
}
192+
193+
publish = version.status == 'release'
194+
195+
pkg {
196+
userOrg = 'twcable'
197+
repo = 'aem'
198+
name = 'Grabbit'
199+
200+
desc = 'The purpose of this project is to provide a reliable and fast solution for copying content from a Source to Destination. Source and destination can be any AEM instances.'
201+
202+
websiteUrl = 'https://github.com/TWCable/grabbit'
203+
issueTrackerUrl = 'https://github.com/TWCable/grabbit/issues'
204+
vcsUrl = 'https://github.com/TWCable/grabbit.git'
205+
licenses = ['Apache-2.0']
206+
labels = ['AEM', 'CQ', 'Content Copy', 'Data Migration']
207+
attributes = ['plat': ['aem', 'cq']]
208+
209+
publicDownloadNumbers = true
210+
211+
//noinspection GroovyAssignabilityCheck
212+
version {
213+
//noinspection GrReassignedInClosureLocalVar
214+
name = project.version.bintrayVersion
215+
vcsTag = 'v' + project.version
216+
}
217+
}
218+
}
219+
220+
bintrayUpload.dependsOn('createPackage')

buildSrc/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apply plugin: 'groovy'
2+
3+
dependencies {
4+
testCompile('org.spockframework:spock-core:1.0-groovy-2.3') {
5+
exclude module: 'groovy-all'
6+
}
7+
}
8+
9+
repositories {
10+
mavenCentral()
11+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* Copyright 2015 Time Warner Cable, Inc.
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+
17+
package com.twcable.grabbit
18+
19+
// **************************************************************************
20+
//
21+
// VERSION CLASS
22+
//
23+
// **************************************************************************
24+
25+
26+
class Version {
27+
String originalVersion
28+
String thisVersion
29+
String status
30+
Date buildTime
31+
32+
33+
Version(String versionValue) {
34+
buildTime = new Date()
35+
originalVersion = versionValue
36+
if (originalVersion.endsWith('-SNAPSHOT')) {
37+
status = 'integration'
38+
thisVersion = originalVersion - 'SNAPSHOT' + getTimestamp()
39+
}
40+
else {
41+
status = 'release'
42+
thisVersion = versionValue
43+
}
44+
}
45+
46+
47+
@SuppressWarnings("UnnecessaryQualifiedReference")
48+
String getTimestamp() {
49+
// Convert local file timestamp to UTC
50+
def format = new java.text.SimpleDateFormat('yyyyMMddHHmmss')
51+
format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')));
52+
return format.format(buildTime)
53+
}
54+
55+
56+
String toString() {
57+
originalVersion
58+
}
59+
60+
61+
String getBintrayVersion() {
62+
thisVersion
63+
}
64+
65+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2015 Time Warner Cable, Inc.
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+
17+
package com.twcable.grabbit
18+
19+
import spock.lang.Specification
20+
21+
class VersionSpec extends Specification {
22+
23+
def "version When Snapshot"(){
24+
given:
25+
final String ver = "Test-SNAPSHOT"
26+
when:
27+
Version version = new Version(ver)
28+
then:
29+
version.thisVersion == ver - "SNAPSHOT" + version.getTimestamp()
30+
}
31+
32+
def "default Version"(){
33+
given:
34+
final String ver = "1.0.5"
35+
when:
36+
Version version = new Version(ver)
37+
then:
38+
version.thisVersion == ver
39+
}
40+
41+
}

0 commit comments

Comments
 (0)