author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Fri, 18 Dec 2020 18:28:32 +0200 | |
changeset 2476 | 9dcca871e859 |
parent 2468 | cab0464c11f4 |
child 2502 | 45513923d474 |
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 |
||
2290
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
14 |
Stopping server |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
15 |
=============== |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
16 |
:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
17 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
18 |
$ gradle --stop |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
19 |
|
2458
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
20 |
Altering user home |
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
21 |
================== |
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
22 |
|
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
23 |
``GRADLE_USER_HOME`` controls user home. |
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
24 |
|
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
25 |
https://docs.gradle.org/current/userguide/build_environment.html |
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
26 |
Build Environment. Gradle properties. ``GRADLE_USER_HOME`` directory. |
28c248a41a85
Altering user home.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2413
diff
changeset
|
27 |
|
2290
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
28 |
Logging |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
29 |
======= |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
30 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
31 |
Gradle uses modified Slf4j: ``org.gradle.api.logging.Logger``. |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
32 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
33 |
Logging level can be set with ``org.gradle.api.logging.LogLevel``:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
34 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
35 |
logger.log(LogLevel.LIFECYCLE, "Unzipping {}...", zipFile); |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
36 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
37 |
``Project`` and ``Task`` has ``logger`` object with levels:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
38 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
39 |
logger.error "..." |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
40 |
logger.quiet "..." |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
41 |
logger.warning "..." |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
42 |
logger.lifecycle "..." |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
43 |
logger.info "..." |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
44 |
logger.debug "..." |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
45 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
46 |
``println`` is printed on ``quiet`` level. |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
47 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
48 |
Make Gradle quiet:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
49 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
50 |
$ gradle -q ... |
2295
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
51 |
$ gradle --quiet ... |
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
52 |
|
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
53 |
Show only errors/warnings:: |
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
54 |
|
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
55 |
$ gradle -w ... |
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
56 |
$ gradle --warn ... |
2290
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
57 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
58 |
Make Gradle verbose:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
59 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
60 |
$ gradle -i ... |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
61 |
$ gradle --info ... |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
62 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
63 |
Make Gradle to print debug output:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
64 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
65 |
$ gradle -d ... |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
66 |
$ gradle --debug ... |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
67 |
|
2351 | 68 |
Debugging Gradle |
69 |
================ |
|
70 |
||
71 |
Enable debugging and disable server mode:: |
|
72 |
||
2352 | 73 |
gradle -Dorg.gradle.debug=true --no-daemon ... |
2351 | 74 |
|
75 |
Then attach by Java debugger to port 5005. |
|
76 |
||
2352 | 77 |
Alternatively:: |
78 |
||
79 |
GRADLE_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005' gradle --no-daemon ... |
|
80 |
||
2353
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
81 |
To investigate interface & values of object:: |
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
82 |
|
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
83 |
println it.metaClass.metaMethods*.name.sort().unique() |
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
84 |
println it.metaClass.methods*.name.sort().unique() |
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
85 |
println it.properties.entrySet()*.toString().sort().toString().replaceAll(", ","\n") |
2467
0498f0cc9966
Extra tips to introspect object properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2458
diff
changeset
|
86 |
println it.properties.toString() |
0498f0cc9966
Extra tips to introspect object properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2458
diff
changeset
|
87 |
println it.dump() |
2353
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
88 |
|
2351 | 89 |
https://docs.gradle.org/current/userguide/troubleshooting.html |
90 |
Attaching a debugger to your build. |
|
2353
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
91 |
https://stackoverflow.com/questions/22203947/how-to-dump-all-gradle-values-used-for-build |
5d8b32fea523
To investigate interface & values of object.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2352
diff
changeset
|
92 |
How to dump all gradle values used for build. |
2351 | 93 |
|
2290
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
94 |
Managing tasks |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
95 |
============== |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
96 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
97 |
List tasks:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
98 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
99 |
$ gradle tasks |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
100 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
101 |
Getting list of supported tasks in each subproject:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
102 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
103 |
$ gradle tasks --all |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
104 |
|
2356 | 105 |
Check execution path or debug task dependencies:: |
106 |
||
107 |
$ gradle -m compile |
|
108 |
$ gradle --dry-run compile |
|
109 |
||
2290
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
110 |
Getting help on task:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
111 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
112 |
$ gradle help --task build |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
113 |
$ gradle -q help --task build |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
114 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
115 |
Similar but to each task:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
116 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
117 |
$ gradle model |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
118 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
119 |
Skip task during build with ``-x`` option:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
120 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
121 |
$ gradle -x test build |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
122 |
$ gradle -x :core:build :client:build |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
123 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
124 |
Skipt task programmatically:: |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
125 |
|
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
126 |
gradle.startParameter.excludedTaskNames.add "jar" |
3b2866390fb7
Reordered sections.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2265
diff
changeset
|
127 |
|
2094
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
128 |
Working with subprojects |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
129 |
======================== |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
130 |
|
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
131 |
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
|
132 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
133 |
$ gradle projects |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
134 |
|
2094
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
135 |
Running build on specific subproject:: |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
136 |
|
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
137 |
$ gradle :$SUB:clean |
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
138 |
$ gradle -p $SUB clean |
2095
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
139 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
140 |
If subproject lies in hierarchy:: |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
141 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
142 |
$ gradle :$SUB/$SUBSUB:clean |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
143 |
$ gradle -p $SUB/$SUBSUB clean |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
144 |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
145 |
Skip building dependent modules, build just current module:: |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
146 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
147 |
$ gradle -a build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
148 |
$ gradle --no-rebuild build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
149 |
$ gradle -a :client:build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
150 |
|
2095
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
151 |
Creating multilevel project:: |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
152 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
153 |
$ mkdir $PRJROOT |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
154 |
$ cd $PRJROOT |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
155 |
$ mkdir lvl1 lvl1/lvl2 |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
156 |
$ touch build.gradle lvl1/build.gradle lvl1/lvl2/build.gradle |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
157 |
$ { echo include "'lvl1'"; echo include "'lvl1/lvl2'"; } >settings.gradle |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
158 |
$ gradle projects |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
159 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
160 |
``settings.gradle`` can include per line or a list of subprojects:: |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
161 |
|
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
162 |
include 'sub1', 'sub2', 'sub2' |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
163 |
include 'lvl1' |
b9bf144836b8
Creating multilevel project.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2094
diff
changeset
|
164 |
include 'lvl1/lvl2' |
2094
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
165 |
|
33c10259cb4d
Running build on specific subproject.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2086
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
|
2293
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
169 |
Debugging build |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
170 |
=============== |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
171 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
172 |
Enable better logging:: |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
173 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
174 |
$ gradle -i ... |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
175 |
$ gradle --info ... |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
176 |
$ gradle -d ... |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
177 |
$ gradle --debug ... |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
178 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
179 |
Enable stacktraces:: |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
180 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
181 |
$ gradle --stacktrace |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
182 |
|
2294
6d97c0b855ef
Review deprecation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2293
diff
changeset
|
183 |
Review deprecation:: |
6d97c0b855ef
Review deprecation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2293
diff
changeset
|
184 |
|
6d97c0b855ef
Review deprecation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2293
diff
changeset
|
185 |
$ gradle --warning-mode=all --stacktrace |
6d97c0b855ef
Review deprecation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2293
diff
changeset
|
186 |
|
2293
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
187 |
Profiling build |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
188 |
=============== |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
189 |
:: |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
190 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
191 |
$ gradle --profile |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
192 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
193 |
To use build scans accept EULA:: |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
194 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
195 |
buildScan { |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
196 |
termsOfServiceUrl = 'https://gradle.com/terms-of-service' |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
197 |
termsOfServiceAgree = 'yes' |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
198 |
} |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
199 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
200 |
then run:: |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
201 |
|
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
202 |
$ gradle --scan |
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
203 |
|
2130
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
204 |
Running completely isolated build |
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
205 |
================================= |
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
206 |
|
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
207 |
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
|
208 |
|
2293
5bbcbb898ebb
Debugging/profiling build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2290
diff
changeset
|
209 |
$ gradle --no-daemon -g _tmp |
2130
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
210 |
$ gradle --no-daemon --gradle-user-home ./.gradle.local |
511c1dd5b010
Running completely isolated build.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2120
diff
changeset
|
211 |
|
2078 | 212 |
Build sources |
213 |
============= |
|
214 |
:: |
|
215 |
||
216 |
$ gradle compileJava |
|
217 |
$ gradle compileTestJava |
|
218 |
||
2118
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
219 |
Build with additional options and checks:: |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
220 |
|
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
221 |
compileJava { |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
222 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
223 |
} |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
224 |
compileTestJava { |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
225 |
options.encoding = 'UTF-8' |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
226 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
227 |
} |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
228 |
|
2119
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
229 |
To apply change recursively to subprojects:: |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
230 |
|
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
231 |
subprojects { |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
232 |
tasks.withType(JavaCompile) { |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
233 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
234 |
} |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
235 |
} |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
236 |
|
2078 | 237 |
Run main class |
238 |
============== |
|
239 |
:: |
|
240 |
||
241 |
$ gradle run |
|
242 |
||
2086 | 243 |
Run tests |
244 |
========= |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
245 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
246 |
To run test:: |
2086 | 247 |
|
248 |
$ gradle test |
|
249 |
||
2248
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
250 |
To select specific test or pattern use ``--tests`` option, like:: |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
251 |
|
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
252 |
$ gradle test --tests com.evil.UtitTest |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
253 |
$ gradle test --tests com.evil.UtitTest.login |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
254 |
$ gradle test --tests '*'BasicTest.login |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
255 |
$ gradle test --tests '*BasicTest.calc*' |
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
256 |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
257 |
To skip tests in build:: |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
258 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
259 |
$ gradle -x test build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
260 |
|
2295
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
261 |
To continue testing after fixing test:: |
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
262 |
|
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
263 |
$ gradle test --continue |
66966fe5239d
Added long option variants.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2294
diff
changeset
|
264 |
|
2248
0498f4c91fda
To select specific test.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2158
diff
changeset
|
265 |
Alternative solution involves passing system property with ``build.gradle``:: |
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
266 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
267 |
test.onlyIf { ! Boolean.getBoolean('skip.tests') } |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
268 |
|
2086 | 269 |
To run tests with additional registered checks:: |
270 |
||
271 |
$ gradle check |
|
272 |
||
273 |
.. note:: |
|
274 |
``--rerun-tasks`` option *specifies that any task optimization is ignored*. |
|
2404
ba68f3bf0e48
How to run Gradle test when all tests are UP-TO-DATE?
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2364
diff
changeset
|
275 |
If you are not using build cache it reruns tests and all dependent tasks:: |
2086 | 276 |
|
277 |
$ gradle test --rerun-tasks |
|
278 |
||
2404
ba68f3bf0e48
How to run Gradle test when all tests are UP-TO-DATE?
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2364
diff
changeset
|
279 |
See https://stackoverflow.com/questions/29427020/how-to-run-gradle-test-when-all-tests-are-up-to-date |
ba68f3bf0e48
How to run Gradle test when all tests are UP-TO-DATE?
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2364
diff
changeset
|
280 |
|
2120 | 281 |
By default ``System.out`` and ``Sysyem.err`` redirected so you wouldn't see |
282 |
anything about test on console. |
|
283 |
||
284 |
Quick way to see test output is:: |
|
285 |
||
286 |
$ gradle test -i |
|
287 |
||
288 |
Alternatively configure ``test`` task:: |
|
289 |
||
290 |
test { |
|
291 |
testLogging { |
|
292 |
events "passed", "skipped", "failed" //, "standardOut", "standardError" |
|
293 |
||
294 |
showExceptions true |
|
295 |
exceptionFormat "full" |
|
296 |
showCauses true |
|
297 |
showStackTraces true |
|
298 |
||
299 |
showStandardStreams = false |
|
300 |
} |
|
301 |
} |
|
302 |
||
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
303 |
List project dependencies |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
304 |
========================= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
305 |
|
2086 | 306 |
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
|
307 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
308 |
$ gradle dependencies |
2086 | 309 |
$ 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
|
310 |
$ 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
|
311 |
$ gradle :$SUBPROJ:dependencies |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
312 |
$ 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
|
313 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
314 |
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
|
315 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
316 |
$ gradle buildEnvironment |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
317 |
$ 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
|
318 |
$ gradle :$SUBPROJ:buildEnvironment |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
319 |
|
2086 | 320 |
Paths to dependencies can be printed via task:: |
321 |
||
322 |
task printDepPaths { |
|
323 |
doLast { configurations.runtime.each { println it } } |
|
324 |
} |
|
325 |
||
326 |
All dependencies can be copied to single directory via task:: |
|
327 |
||
328 |
task copyRuntimeLibs(type: Copy) { |
|
329 |
into "lib" |
|
330 |
from configurations.runtime |
|
331 |
// from configurations.testRuntime - configurations.runtime |
|
332 |
} |
|
333 |
||
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
334 |
List of configurations:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
335 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
336 |
configurations.each { println it.name } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
337 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
338 |
For each configuration ``build<ConfigurationName>`` and ``upload<ConfigurationName>`` are defined. |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
339 |
|
2264
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
340 |
Configuring external dependencies |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
341 |
================================= |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
342 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
343 |
Adding large well known artifact repositories:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
344 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
345 |
repositories { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
346 |
mavenCentral() |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
347 |
jcenter() |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
348 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
349 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
350 |
``mavelLocal()`` for local ``~/.m2`` or whenever Maven ``settings.xml`` is pointing. |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
351 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
352 |
Adding custom repositories:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
353 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
354 |
repositories { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
355 |
maven { url "http://repo.example.com/maven2" } |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
356 |
ivy { url "http://repo.example.com/ivy" } |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
357 |
maven { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
358 |
url "http://repo.example.com/maven2" |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
359 |
username "ro-user" |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
360 |
password "pas$$word" |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
361 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
362 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
363 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
364 |
Excluding transitive dependencies:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
365 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
366 |
compile 'org.springframework:spring-web:4.3.10.RELEASE' { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
367 |
exclude group: 'com.google.code.gson', module: 'gson' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
368 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
369 |
|
2363
f71d7d499489
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2356
diff
changeset
|
370 |
implementation project(':core'), { |
f71d7d499489
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2356
diff
changeset
|
371 |
exclude group: 'org.quartz-scheduler' |
f71d7d499489
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2356
diff
changeset
|
372 |
} |
f71d7d499489
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2356
diff
changeset
|
373 |
|
2264
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
374 |
configurations.all { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
375 |
exclude group: 'com.google.code.gson', module: 'gson' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
376 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
377 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
378 |
configurations.runtime { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
379 |
exclude group: 'com.google.code.gson', module: 'gson' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
380 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
381 |
|
2364
3ae6885e729f
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2363
diff
changeset
|
382 |
configurations { |
3ae6885e729f
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2363
diff
changeset
|
383 |
implementation { |
3ae6885e729f
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2363
diff
changeset
|
384 |
exclude group: 'javax.jms', module: 'jms' |
3ae6885e729f
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2363
diff
changeset
|
385 |
} |
3ae6885e729f
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2363
diff
changeset
|
386 |
} |
3ae6885e729f
Excluding transitive dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2363
diff
changeset
|
387 |
|
2264
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
388 |
Forcing a specific version of a transitive dependency:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
389 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
390 |
configurations.all { |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
391 |
resolutionStrategy.force 'com.google.code.gson:gson:2.8.1' |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
392 |
} |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
393 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
394 |
Declaring dependency on module in multi-module build:: |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
395 |
|
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
396 |
compile project(':core') |
abede030dc1d
Configuring external dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2263
diff
changeset
|
397 |
|
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
398 |
List project properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
399 |
======================= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
400 |
:: |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
401 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
402 |
$ gradle properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
403 |
$ gradle :$SUBPROJ:properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
404 |
$ 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
|
405 |
|
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
406 |
Well known properties |
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 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
409 |
``rootDir``, ``projectDir``, ``buildDir`` are of ``java.io.File`` type. |
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 |
``tasks`` refers to task set. |
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 |
``project``, ``subprojects``, ``rootProject`` refer to various Project instances. |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
414 |
|
2158
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
415 |
Bootstrap project structure |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
416 |
=========================== |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
417 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
418 |
This creates simple project with Gradle boilerplate files:: |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
419 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
420 |
$ gradle init --type java-library |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
421 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
422 |
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
|
423 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
424 |
$ gradle init --type pom |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
425 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
426 |
https://docs.gradle.org/current/userguide/build_init_plugin.html |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
427 |
Official docs on ``init`` plugin. |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
428 |
|
2157 | 429 |
Gradle wrapper |
430 |
============== |
|
431 |
||
432 |
With Gradle v2.4 and above:: |
|
433 |
||
434 |
$ cd $PROJ |
|
435 |
$ gradle wrapper --gradle-version 3.5 |
|
436 |
||
437 |
It will add ``gradle/wrapper/gradle-wrapper.jar`` to project root and next call |
|
438 |
to ``./gradlew`` download Gradle distribution from ``distributionUrl`` parameter |
|
439 |
from ``gradle/wrapper/gradle-wrapper.properties`` file. Dictribution will be |
|
440 |
cached in ``~/.gradle/wrapper/dists.gradle/wrapper/dists`` directory so next |
|
441 |
calls won't require download. |
|
442 |
||
443 |
Alternatively define task:: |
|
444 |
||
445 |
task wrapper(type: Wrapper) { |
|
446 |
gradleVersion = '2.0' |
|
447 |
} |
|
448 |
||
2265
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
449 |
Update Gradle wrapper version with:: |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
450 |
|
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
451 |
$ gradle --version |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
452 |
Gradle 4.0.1 |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
453 |
$ gradle wrapper --gradle-version 4.9 |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
454 |
|
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
455 |
To increase security add ``distributionSha256Sum`` parameter to ``gradle-wrapper.properties`` file. |
31e11d79a712
Update Gradle wrapper.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2264
diff
changeset
|
456 |
Distribution SHA-256 sum can be obtained via ``shasum`` utility. |
2157 | 457 |
|
458 |
https://docs.gradle.org/current/userguide/gradle_wrapper.html |
|
459 |
Official docs. |
|
460 |
||
2468
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
461 |
Migrating to newer Gradle |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
462 |
========================= |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
463 |
|
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
464 |
Try to eliminate all deprecation warnings:: |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
465 |
|
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
466 |
./gradlew testClasses --warning-mode all |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
467 |
|
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
468 |
Update Gradle distro to newer version:: |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
469 |
|
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
470 |
./gradlew wrapper --gradle-version 6.7 |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
471 |
|
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
472 |
Try to eliminate another portion of deprecation warnings and run build/tests:: |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
473 |
|
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
474 |
./gradlew test --warning-mode all |
cab0464c11f4
Migrating to newer Gradle.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2467
diff
changeset
|
475 |
|
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
476 |
Managing Gradle cache |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
477 |
===================== |
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
478 |
|
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
479 |
Work in offline mode with ``--offline`` option. |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
480 |
|
2120 | 481 |
Invalidate cache (force re-downloading dependencies) with |
482 |
``--refresh-dependencies`` option. |
|
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
483 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
484 |
Alternatively remove ``~/.m2/repository/`` and ``~/.gradle/caches`` directories. |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
485 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
486 |
Gradle cached modules declared as *changing*:: |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
487 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
488 |
dependencies { |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
489 |
compile("com.evil:evil-api:1.0.1-SNAPSHOT") { changing=true } |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
490 |
} |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
491 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
492 |
Default timeout is 24 hours and can be reset/changed via:: |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
493 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
494 |
configurations.all { |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
495 |
resolutionStrategy.cacheChangingModulesFor 0, 'seconds' |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
496 |
} |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
497 |
|
2117
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
498 |
Download sources and javadoc of dependencies |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
499 |
============================================ |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
500 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
501 |
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
|
502 |
``idea`` plugin to your ``build.gradle``:: |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
503 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
504 |
apply plugin: 'idea' |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
505 |
idea.module.downloadJavadoc = true |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
506 |
idea.module.downloadSources = true |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
507 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
508 |
and invoke plugin:: |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
509 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
510 |
$ gradle idea |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
511 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
512 |
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
|
513 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
514 |
$ gradle cleanIdea |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
515 |
|
2263
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
516 |
Dependencies between tasks |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
517 |
========================== |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
518 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
519 |
Direct dependency:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
520 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
521 |
task A { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
522 |
dependsOn B, C |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
523 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
524 |
A.dependsOn D, E |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
525 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
526 |
Cleanup actions:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
527 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
528 |
task A { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
529 |
dependsOn startServer |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
530 |
finalizedBy stopServer |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
531 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
532 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
533 |
To enforce order without enforcing dependency:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
534 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
535 |
task A { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
536 |
mustRunAfter B |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
537 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
538 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
539 |
Declare dependencies programmatically:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
540 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
541 |
dependsOn project.tasks.matching { it.name.endsWith "Test" } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
542 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
543 |
Apply task on condition:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
544 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
545 |
task upload { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
546 |
onlyIf { System.getProperty("debug") != null } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
547 |
doLast { println "In debug mode." } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
548 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
549 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
550 |
Accessing task graph |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
551 |
==================== |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
552 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
553 |
Process task graph when it is already populated:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
554 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
555 |
gradle.taskGraph.whenReady { graph -> |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
556 |
if (graph.hasTask(":release")) { ... } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
557 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
558 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
559 |
``gradle.taskGraph`` is safe to access inside ``doFirst`` / ``doLast``:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
560 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
561 |
task someTask { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
562 |
doLast { |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
563 |
if (gradle.taskGraph.hasTask(":someTask")) { } |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
564 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
565 |
} |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
566 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
567 |
List all tasks that will be executed in current build:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
568 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
569 |
println gradle.taskGraph.allTasks |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
570 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
571 |
Applying pluings |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
572 |
================ |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
573 |
:: |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
574 |
|
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
575 |
apply from: "plugins/my.gradle" |
0243bb26fe02
List of configurations.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2248
diff
changeset
|
576 |
|
2413
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
577 |
Publishing artifacts |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
578 |
==================== |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
579 |
|
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
580 |
https://docs.gradle.org/current/userguide/publishing_setup.html |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
581 |
Publishing a project as module. |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
582 |
https://docs.gradle.org/current/userguide/publishing_customization.html |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
583 |
Customizing publishing. |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
584 |
https://www.jfrog.com/confluence/display/JFROG/Gradle+Artifactory+Plugin |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
585 |
Gradle Artifactory Plugin. |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
586 |
https://github.com/jfrog/build-info |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
587 |
Project that holds Artifactory integration for Gradle (``build-info-extractor-gradle``). |
ceca880171c3
Gradle Artifactory Plugin.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2404
diff
changeset
|
588 |