Skip to content

Commit 9caf73c

Browse files
abirkhan04pedja4
authored andcommitted
Gradle tutorial project : (eugenp#2922)
* Gradle tutorial project : 1. A multi-project build 2. Inclusive all required tasks and dependency example. * Gradle tutorial is shifted to gradle folder
1 parent 9f49798 commit 9caf73c

29 files changed

Lines changed: 407 additions & 53 deletions

File tree

‎gradle/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.gradle/

‎gradle/.travis.yml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# More details on how to configure the Travis build
2+
# https://docs.travis-ci.com/user/customizing-the-build/
3+
4+
# Speed up build with travis caches
5+
cache:
6+
directories:
7+
- $HOME/.gradle/caches/
8+
- $HOME/.gradle/wrapper/
9+
10+
language: java
11+
12+
jdk:
13+
- oraclejdk8
14+
15+
#Skipping install step to avoid having Travis run arbitrary './gradlew assemble' task
16+
# https://docs.travis-ci.com/user/customizing-the-build/#Skipping-the-Installation-Step
17+
install:
18+
- true
19+
20+
#Don't build tags
21+
branches:
22+
except:
23+
- /^v\d/
24+
25+
#Build and perform release (if needed)
26+
script:
27+
- ./gradlew build -s && ./gradlew ciPerformRelease

‎gradle/build.gradle‎

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
apply plugin: 'java'
2-
apply plugin: 'maven'
1+
allprojects {
2+
repositories {
3+
jcenter()
4+
}
5+
}
6+
7+
8+
subprojects {
39

4-
repositories{
5-
mavenCentral()
10+
version = '1.0'
611
}
712

8-
dependencies{
9-
compile 'org.springframework:spring-context:4.3.5.RELEASE'
10-
}
13+
apply plugin: 'eclipse'
14+
15+
println 'This will be executed during the configuration phase.'
16+
17+
task configured {
18+
println 'This will also be executed during the configuration phase.'
19+
}
1120

12-
task hello {
13-
println "this Baeldung's tutorial is ${awesomeness}"
21+
task execFirstTest {
22+
doLast {
23+
println 'This will be executed during the execution phase.'
24+
}
1425
}
1526

16-
uploadArchives {
17-
repositories {
18-
mavenDeployer {
19-
repository(url: 'http://yourmavenrepo/repository') {
20-
authentication(userName: 'user', password: 'password');
21-
}
22-
23-
}
24-
}
27+
task execSecondTest {
28+
doFirst {
29+
println 'This will be executed first during the execution phase.'
30+
}
31+
doLast {
32+
println 'This will be executed last during the execution phase.'
33+
}
34+
println 'This will be executed during the configuration phase as well.'
2535
}

‎gradle/gradle.properties‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎gradle/gradle/shipkit.gradle‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//This default Shipkit configuration file was created automatically and is intended to be checked-in.
2+
//Default configuration is sufficient for local testing and trying out Shipkit.
3+
//To leverage Shipkit fully, please fix the TODO items, refer to our Getting Started Guide for help:
4+
//
5+
// https://github.com/mockito/shipkit/blob/master/docs/getting-started.md
6+
//
7+
shipkit {
8+
//TODO is the repository correct?
9+
gitHub.repository = "unspecified-user/unspecified-repo"
10+
11+
//TODO generate and use your own read-only GitHub personal access token
12+
gitHub.readOnlyAuthToken = "76826c9ec886612f504d12fd4268b16721c4f85d"
13+
14+
//TODO generate GitHub write token, and ensure your Travis CI has this env variable exported
15+
gitHub.writeAuthToken = System.getenv("GH_WRITE_TOKEN")
16+
}
17+
18+
allprojects {
19+
plugins.withId("com.jfrog.bintray") {
20+
21+
//Bintray configuration is handled by JFrog Bintray Gradle Plugin
22+
//For reference see the official documentation: https://github.com/bintray/gradle-bintray-plugin
23+
bintray {
24+
25+
//TODO sign up for free open source account with https://bintray.com, then look up your API key on your profile page in Bintray
26+
key = '7ea297848ca948adb7d3ee92a83292112d7ae989'
27+
//TODO don't check in the key, remove above line and use env variable exported on CI:
28+
//key = System.getenv("BINTRAY_API_KEY")
29+
30+
pkg {
31+
//TODO configure Bintray settings per your project (https://github.com/bintray/gradle-bintray-plugin)
32+
repo = 'bootstrap'
33+
user = 'shipkit-bootstrap-bot'
34+
userOrg = 'shipkit-bootstrap'
35+
name = 'maven'
36+
licenses = ['MIT']
37+
labels = ['continuous delivery', 'release automation', 'shipkit']
38+
}
39+
}
40+
}
41+
}
-52.3 KB
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Dec 31 15:46:08 BRT 2016
1+
#Thu Oct 12 16:43:02 BDT 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-bin.zip
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
task fromPlugin {
2+
doLast {
3+
println "I'm from plugin"
4+
}
5+
}

‎gradle/gradletaskdemo/build.gradle‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
buildscript {
2+
repositories {
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
5+
}
6+
}
7+
dependencies {
8+
classpath "org.shipkit:shipkit:0.9.117"
9+
}
10+
}
11+
12+
13+
plugins {
14+
id 'java'
15+
}
16+
17+
18+
apply from: 'aplugin.gradle'
19+
apply plugin: 'org.shipkit.bintray-release'
20+
21+
22+
//hello task
23+
task hello {
24+
doLast {
25+
println 'Baeldung'
26+
}
27+
}
28+
29+
//Groovy in gradle task
30+
task toLower {
31+
doLast {
32+
String someString = 'HELLO FROM BAELDUNG'
33+
println "Original: " + someString
34+
println "Lower case: " + someString.toLowerCase()
35+
}
36+
}
37+
38+
39+
// Task dependencies
40+
task helloGradle {
41+
doLast {
42+
println 'Hello Gradle!'
43+
}
44+
}
45+
46+
task fromBaeldung(dependsOn: helloGradle) {
47+
doLast {
48+
println "I'm from Baeldung"
49+
}
50+
}
51+
52+
53+
//Adding behavior to a task via api
54+
task helloBaeldung {
55+
doLast {
56+
println 'I will be executed second'
57+
}
58+
}
59+
60+
helloBaeldung.doFirst {
61+
println 'I will be executed first'
62+
}
63+
64+
helloBaeldung.doLast {
65+
println 'I will be executed third'
66+
}
67+
68+
helloBaeldung {
69+
doLast {
70+
println 'I will be executed fourth'
71+
}
72+
}
73+
74+
75+
76+
77+
//Adding extra task properties
78+
task ourTask {
79+
ext.theProperty = "theValue"
80+
}
81+
82+
task printTaskProperty {
83+
doLast {
84+
println ourTask.theProperty
85+
}
86+
}
87+
88+
89+
90+
//Declaring dependencies
91+
dependencies {
92+
compile group:
93+
'org.springframework', name: 'spring-core', version: '4.3.5.RELEASE'
94+
compile 'org.springframework:spring-core:4.3.5.RELEASE',
95+
'org.springframework:spring-aop:4.3.5.RELEASE'
96+
compile(
97+
[group: 'org.springframework', name: 'spring-core', version: '4.3.5.RELEASE'],
98+
[group: 'org.springframework', name: 'spring-aop', version: '4.3.5.RELEASE']
99+
)
100+
testCompile('org.hibernate:hibernate-core:5.2.12.Final') {
101+
transitive = true
102+
}
103+
runtime(group: 'org.hibernate', name: 'hibernate-core', version: '5.2.12.Final') {
104+
transitive = false
105+
}
106+
runtime "org.codehaus.groovy:groovy-all:2.4.11@jar"
107+
runtime group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.11', ext: 'jar'
108+
109+
compile fileTree(dir: 'libs', include: '*.jar')
110+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+

0 commit comments

Comments
 (0)