author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sun, 07 Oct 2018 23:53:10 +0300 | |
changeset 2272 | 46e6d01a6e3f |
parent 2265 | 31e11d79a712 |
child 2290 | 3b2866390fb7 |
permissions | -rw-r--r-- |
2078 | 1 |
|
2 |
======== |
|
3 |
Gradle |
|
4 |
======== |
|
5 |
.. contents:: |
|
6 |
:local: |
|
7 |
||
8 |
Getting help |
|
9 |
============ |
|
10 |
:: |
|
11 |
||
12 |
$ gradle --help |
|
13 |
||
2094
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
14 |
Working with subprojects |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
15 |
======================== |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
16 |
|
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
17 |
Getting list of subprojects:: |
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
18 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
19 |
$ gradle projects |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
20 |
|
2094
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
21 |
Running build on specific subproject:: |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
22 |
|
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
23 |
$ gradle :$SUB:clean |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
24 |
$ gradle -p $SUB clean |
2095
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
25 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
26 |
If subproject lies in hierarchy:: |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
27 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
28 |
$ gradle :$SUB/$SUBSUB:clean |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
29 |
$ gradle -p $SUB/$SUBSUB clean |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
30 |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
31 |
Skip building dependent modules, build just current module:: |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
32 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
33 |
$ gradle -a build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
34 |
$ gradle --no-rebuild build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
35 |
$ gradle -a :client:build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
36 |
|
2095
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
37 |
Creating multilevel project:: |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
38 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
39 |
$ mkdir $PRJROOT |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
40 |
$ cd $PRJROOT |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
41 |
$ mkdir lvl1 lvl1/lvl2 |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
42 |
$ touch build.gradle lvl1/build.gradle lvl1/lvl2/build.gradle |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
43 |
$ { echo include "'lvl1'"; echo include "'lvl1/lvl2'"; } >settings.gradle |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
44 |
$ gradle projects |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
45 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
46 |
``settings.gradle`` can include per line or a list of subprojects:: |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
47 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
48 |
include 'sub1', 'sub2', 'sub2' |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
49 |
include 'lvl1' |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
50 |
include 'lvl1/lvl2' |
2094
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
51 |
|
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
52 |
https://docs.gradle.org/current/userguide/intro_multi_project_builds.html |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
53 |
http://stackoverflow.com/questions/16976214/gradle-build-only-one-module |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
54 |
|
2130
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
55 |
Running completely isolated build |
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
56 |
================================= |
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
57 |
|
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
58 |
To avoid using global cache and for really clean build use:: |
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
59 |
|
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
60 |
$ gradle --no-daemon --gradle-user-home ./.gradle.local |
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
61 |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
62 |
Managing tasks |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
63 |
============== |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
64 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
65 |
List tasks:: |
2078 | 66 |
|
67 |
$ gradle tasks |
|
68 |
||
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
69 |
Getting list of supported tasks in each subproject:: |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
70 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
71 |
$ gradle tasks --all |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
72 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
73 |
Getting help on task:: |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
74 |
|
2156
de9f7c02b6e9
Example without suppressing additional output.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2130
diff
changeset
|
75 |
$ gradle help --task build |
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
76 |
$ gradle -q help --task build |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
77 |
|
2086 | 78 |
Similar but to each task:: |
79 |
||
80 |
$ gradle model |
|
81 |
||
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
82 |
Skip task during build with ``-x`` option:: |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
83 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
84 |
$ gradle -x test build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
85 |
$ gradle -x :core:build :client:build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
86 |
|
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
87 |
Skipt task programmatically:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
88 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
89 |
gradle.startParameter.excludedTaskNames.add "jar" |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
90 |
|
2078 | 91 |
Build sources |
92 |
============= |
|
93 |
:: |
|
94 |
||
95 |
$ gradle compileJava |
|
96 |
$ gradle compileTestJava |
|
97 |
||
2118
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
98 |
Build with additional options and checks:: |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
99 |
|
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
100 |
compileJava { |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
101 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
102 |
} |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
103 |
compileTestJava { |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
104 |
options.encoding = 'UTF-8' |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
105 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
106 |
} |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
107 |
|
2119
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
108 |
To apply change recursively to subprojects:: |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
109 |
|
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
110 |
subprojects { |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
111 |
tasks.withType(JavaCompile) { |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
112 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
113 |
} |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
114 |
} |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
115 |
|
2078 | 116 |
Run main class |
117 |
============== |
|
118 |
:: |
|
119 |
||
120 |
$ gradle run |
|
121 |
||
2086 | 122 |
Run tests |
123 |
========= |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
124 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
125 |
To run test:: |
2086 | 126 |
|
127 |
$ gradle test |
|
128 |
||
2248
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
129 |
To select specific test or pattern use ``--tests`` option, like:: |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
130 |
|
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
131 |
$ gradle test --tests com.evil.UtitTest |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
132 |
$ gradle test --tests com.evil.UtitTest.login |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
133 |
$ gradle test --tests '*'BasicTest.login |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
134 |
$ gradle test --tests '*BasicTest.calc*' |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
135 |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
136 |
To skip tests in build:: |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
137 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
138 |
$ gradle -x test build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
139 |
|
2248
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
140 |
Alternative solution involves passing system property with ``build.gradle``:: |
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
141 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
142 |
test.onlyIf { ! Boolean.getBoolean('skip.tests') } |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
143 |
|
2086 | 144 |
To run tests with additional registered checks:: |
145 |
||
146 |
$ gradle check |
|
147 |
||
148 |
.. note:: |
|
149 |
``--rerun-tasks`` option *specifies that any task optimization is ignored*. |
|
150 |
In that way you may rerun tests even if there are no changed files:: |
|
151 |
||
152 |
$ gradle test --rerun-tasks |
|
153 |
||
2120 | 154 |
By default ``System.out`` and ``Sysyem.err`` redirected so you wouldn't see |
155 |
anything about test on console. |
|
156 |
||
157 |
Quick way to see test output is:: |
|
158 |
||
159 |
$ gradle test -i |
|
160 |
||
161 |
Alternatively configure ``test`` task:: |
|
162 |
||
163 |
test { |
|
164 |
testLogging { |
|
165 |
events "passed", "skipped", "failed" //, "standardOut", "standardError" |
|
166 |
||
167 |
showExceptions true |
|
168 |
exceptionFormat "full" |
|
169 |
showCauses true |
|
170 |
showStackTraces true |
|
171 |
||
172 |
showStandardStreams = false |
|
173 |
} |
|
174 |
} |
|
175 |
||
2078 | 176 |
Stopping server |
177 |
=============== |
|
178 |
:: |
|
179 |
||
180 |
$ gradle --stop |
|
181 |
||
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
182 |
List project dependencies |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
183 |
========================= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
184 |
|
2086 | 185 |
List of project execution dependencies (it also download dependencies):: |
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
186 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
187 |
$ gradle dependencies |
2086 | 188 |
$ gradle dependencies --configuration compile |
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
189 |
$ gradle dependencies -p $SUBPROJ |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
190 |
$ gradle :$SUBPROJ:dependencies |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
191 |
$ gradle :$SUBPROJ:dependencies --configuration testCompile |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
192 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
193 |
List of project plugin dependencies:: |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
194 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
195 |
$ gradle buildEnvironment |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
196 |
$ gradle buildEnvironment -p $SUBPROJ |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
197 |
$ gradle :$SUBPROJ:buildEnvironment |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
198 |
|
2086 | 199 |
Paths to dependencies can be printed via task:: |
200 |
||
201 |
task printDepPaths { |
|
202 |
doLast { configurations.runtime.each { println it } } |
|
203 |
} |
|
204 |
||
205 |
All dependencies can be copied to single directory via task:: |
|
206 |
||
207 |
task copyRuntimeLibs(type: Copy) { |
|
208 |
into "lib" |
|
209 |
from configurations.runtime |
|
210 |
// from configurations.testRuntime - configurations.runtime |
|
211 |
} |
|
212 |
||
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
213 |
List of configurations:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
214 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
215 |
configurations.each { println it.name } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
216 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
217 |
For each configuration ``build<ConfigurationName>`` and ``upload<ConfigurationName>`` are defined. |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
218 |
|
2264
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
219 |
Configuring external dependencies |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
220 |
================================= |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
221 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
222 |
Adding large well known artifact repositories:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
223 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
224 |
repositories { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
225 |
mavenCentral() |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
226 |
jcenter() |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
227 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
228 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
229 |
``mavelLocal()`` for local ``~/.m2`` or whenever Maven ``settings.xml`` is pointing. |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
230 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
231 |
Adding custom repositories:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
232 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
233 |
repositories { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
234 |
maven { url "http://repo.example.com/maven2" } |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
235 |
ivy { url "http://repo.example.com/ivy" } |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
236 |
maven { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
237 |
url "http://repo.example.com/maven2" |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
238 |
username "ro-user" |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
239 |
password "pas$$word" |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
240 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
241 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
242 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
243 |
Excluding transitive dependencies:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
244 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
245 |
compile 'org.springframework:spring-web:4.3.10.RELEASE' { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
246 |
exclude group: 'com.google.code.gson', module: 'gson' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
247 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
248 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
249 |
configurations.all { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
250 |
exclude group: 'com.google.code.gson', module: 'gson' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
251 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
252 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
253 |
configurations.runtime { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
254 |
exclude group: 'com.google.code.gson', module: 'gson' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
255 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
256 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
257 |
Forcing a specific version of a transitive dependency:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
258 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
259 |
configurations.all { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
260 |
resolutionStrategy.force 'com.google.code.gson:gson:2.8.1' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
261 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
262 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
263 |
Declaring dependency on module in multi-module build:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
264 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
265 |
compile project(':core') |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
266 |
|
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
267 |
List project properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
268 |
======================= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
269 |
:: |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
270 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
271 |
$ gradle properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
272 |
$ gradle :$SUBPROJ:properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
273 |
$ gradle properties -p $SUBPROJ |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
274 |
|
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
275 |
Well known properties |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
276 |
===================== |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
277 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
278 |
``rootDir``, ``projectDir``, ``buildDir`` are of ``java.io.File`` type. |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
279 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
280 |
``tasks`` refers to task set. |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
281 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
282 |
``project``, ``subprojects``, ``rootProject`` refer to various Project instances. |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
283 |
|
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
284 |
Dry tun |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
285 |
======= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
286 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
287 |
``-m`` option allow parsing build scripts without actually executing them:: |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
288 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
289 |
$ gradle -m clean compile |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
290 |
|
2158
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
291 |
Bootstrap project structure |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
292 |
=========================== |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
293 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
294 |
This creates simple project with Gradle boilerplate files:: |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
295 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
296 |
$ gradle init --type java-library |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
297 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
298 |
To convert Maven project (with ``pom.xml`` file) to Gradle project use:: |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
299 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
300 |
$ gradle init --type pom |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
301 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
302 |
https://docs.gradle.org/current/userguide/build_init_plugin.html |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
303 |
Official docs on ``init`` plugin. |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
304 |
|
2157 | 305 |
Gradle wrapper |
306 |
============== |
|
307 |
||
308 |
With Gradle v2.4 and above:: |
|
309 |
||
310 |
$ cd $PROJ |
|
311 |
$ gradle wrapper --gradle-version 3.5 |
|
312 |
||
313 |
It will add ``gradle/wrapper/gradle-wrapper.jar`` to project root and next call |
|
314 |
to ``./gradlew`` download Gradle distribution from ``distributionUrl`` parameter |
|
315 |
from ``gradle/wrapper/gradle-wrapper.properties`` file. Dictribution will be |
|
316 |
cached in ``~/.gradle/wrapper/dists.gradle/wrapper/dists`` directory so next |
|
317 |
calls won't require download. |
|
318 |
||
319 |
Alternatively define task:: |
|
320 |
||
321 |
task wrapper(type: Wrapper) { |
|
322 |
gradleVersion = '2.0' |
|
323 |
} |
|
324 |
||
2265
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
325 |
Update Gradle wrapper version with:: |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
326 |
|
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
327 |
$ gradle --version |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
328 |
Gradle 4.0.1 |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
329 |
$ gradle wrapper --gradle-version 4.9 |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
330 |
|
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
331 |
To increase security add ``distributionSha256Sum`` parameter to ``gradle-wrapper.properties`` file. |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
332 |
Distribution SHA-256 sum can be obtained via ``shasum`` utility. |
2157 | 333 |
|
334 |
https://docs.gradle.org/current/userguide/gradle_wrapper.html |
|
335 |
Official docs. |
|
336 |
||
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
337 |
Managing Gradle cache |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
338 |
===================== |
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
339 |
|
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
340 |
Work in offline mode with ``--offline`` option. |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
341 |
|
2120 | 342 |
Invalidate cache (force re-downloading dependencies) with |
343 |
``--refresh-dependencies`` option. |
|
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
344 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
345 |
Alternatively remove ``~/.m2/repository/`` and ``~/.gradle/caches`` directories. |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
346 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
347 |
Gradle cached modules declared as *changing*:: |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
348 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
349 |
dependencies { |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
350 |
compile("com.evil:evil-api:1.0.1-SNAPSHOT") { changing=true } |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
351 |
} |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
352 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
353 |
Default timeout is 24 hours and can be reset/changed via:: |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
354 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
355 |
configurations.all { |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
356 |
resolutionStrategy.cacheChangingModulesFor 0, 'seconds' |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
357 |
} |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
358 |
|
2117
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
359 |
Download sources and javadoc of dependencies |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
360 |
============================================ |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
361 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
362 |
To download sources and javadoc of dependencies to local ``~/.gradle`` cache add |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
363 |
``idea`` plugin to your ``build.gradle``:: |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
364 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
365 |
apply plugin: 'idea' |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
366 |
idea.module.downloadJavadoc = true |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
367 |
idea.module.downloadSources = true |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
368 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
369 |
and invoke plugin:: |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
370 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
371 |
$ gradle idea |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
372 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
373 |
To wipe out Idea projects file after plug-in run:: |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
374 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
375 |
$ gradle cleanIdea |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
376 |
|
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
377 |
Logging |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
378 |
======= |
2117
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
379 |
|
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
380 |
``Project`` and ``Task`` has ``logger`` object with levels:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
381 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
382 |
logger.error "..." |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
383 |
logger.quiet "..." |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
384 |
logger.warning "..." |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
385 |
logger.lifecycle "..." |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
386 |
logger.info "..." |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
387 |
logger.debug "..." |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
388 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
389 |
``println`` is printed on ``quiet`` level. |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
390 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
391 |
Make Gradle quiet:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
392 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
393 |
$ gradle -q ... |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
394 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
395 |
Make Gradle verbose:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
396 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
397 |
$ gradle -i ... |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
398 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
399 |
Make Gradle to print debug output:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
400 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
401 |
$ gradle -d ... |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
402 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
403 |
Dependencies between tasks |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
404 |
========================== |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
405 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
406 |
Direct dependency:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
407 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
408 |
task A { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
409 |
dependsOn B, C |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
410 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
411 |
A.dependsOn D, E |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
412 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
413 |
Cleanup actions:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
414 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
415 |
task A { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
416 |
dependsOn startServer |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
417 |
finalizedBy stopServer |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
418 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
419 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
420 |
To enforce order without enforcing dependency:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
421 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
422 |
task A { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
423 |
mustRunAfter B |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
424 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
425 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
426 |
Declare dependencies programmatically:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
427 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
428 |
dependsOn project.tasks.matching { it.name.endsWith "Test" } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
429 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
430 |
Apply task on condition:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
431 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
432 |
task upload { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
433 |
onlyIf { System.getProperty("debug") != null } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
434 |
doLast { println "In debug mode." } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
435 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
436 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
437 |
Accessing task graph |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
438 |
==================== |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
439 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
440 |
Process task graph when it is already populated:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
441 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
442 |
gradle.taskGraph.whenReady { graph -> |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
443 |
if (graph.hasTask(":release")) { ... } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
444 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
445 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
446 |
``gradle.taskGraph`` is safe to access inside ``doFirst`` / ``doLast``:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
447 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
448 |
task someTask { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
449 |
doLast { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
450 |
if (gradle.taskGraph.hasTask(":someTask")) { } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
451 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
452 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
453 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
454 |
List all tasks that will be executed in current build:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
455 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
456 |
println gradle.taskGraph.allTasks |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
457 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
458 |
Applying pluings |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
459 |
================ |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
460 |
:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
461 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
462 |
apply from: "plugins/my.gradle" |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
463 |