author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sat, 10 Feb 2018 01:28:53 +0200 | |
changeset 2227 | 1e9323e7ec88 |
parent 2158 | 4273aeaa0c1a |
child 2248 | 0498f4c91fda |
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 |
|
2078 | 87 |
Build sources |
88 |
============= |
|
89 |
:: |
|
90 |
||
91 |
$ gradle compileJava |
|
92 |
$ gradle compileTestJava |
|
93 |
||
2118
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
94 |
Build with additional options and checks:: |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
95 |
|
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
96 |
compileJava { |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
97 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
98 |
} |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
99 |
compileTestJava { |
df69c36275d6
Build with additional options and checks.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2117
diff
changeset
|
100 |
options.encoding = 'UTF-8' |
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 |
|
2119
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
104 |
To apply change recursively to subprojects:: |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
105 |
|
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
106 |
subprojects { |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
107 |
tasks.withType(JavaCompile) { |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
108 |
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" |
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 |
} |
3fd683bb6af2
Apply change recursively to subprojects.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2118
diff
changeset
|
111 |
|
2078 | 112 |
Run main class |
113 |
============== |
|
114 |
:: |
|
115 |
||
116 |
$ gradle run |
|
117 |
||
2086 | 118 |
Run tests |
119 |
========= |
|
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
120 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
121 |
To run test:: |
2086 | 122 |
|
123 |
$ gradle test |
|
124 |
||
2104
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
125 |
To skip tests in build:: |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
126 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
127 |
$ gradle -x test build |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
128 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
129 |
Better solution involves passing system property with ``build.gradle``:: |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
130 |
|
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
131 |
test.onlyIf { ! Boolean.getBoolean('skip.tests') } |
6931c02bbc0e
Skipping tasks and dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2095
diff
changeset
|
132 |
|
2086 | 133 |
To run tests with additional registered checks:: |
134 |
||
135 |
$ gradle check |
|
136 |
||
137 |
.. note:: |
|
138 |
``--rerun-tasks`` option *specifies that any task optimization is ignored*. |
|
139 |
In that way you may rerun tests even if there are no changed files:: |
|
140 |
||
141 |
$ gradle test --rerun-tasks |
|
142 |
||
2120 | 143 |
By default ``System.out`` and ``Sysyem.err`` redirected so you wouldn't see |
144 |
anything about test on console. |
|
145 |
||
146 |
Quick way to see test output is:: |
|
147 |
||
148 |
$ gradle test -i |
|
149 |
||
150 |
Alternatively configure ``test`` task:: |
|
151 |
||
152 |
test { |
|
153 |
testLogging { |
|
154 |
events "passed", "skipped", "failed" //, "standardOut", "standardError" |
|
155 |
||
156 |
showExceptions true |
|
157 |
exceptionFormat "full" |
|
158 |
showCauses true |
|
159 |
showStackTraces true |
|
160 |
||
161 |
showStandardStreams = false |
|
162 |
} |
|
163 |
} |
|
164 |
||
2078 | 165 |
Stopping server |
166 |
=============== |
|
167 |
:: |
|
168 |
||
169 |
$ gradle --stop |
|
170 |
||
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
171 |
List project dependencies |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
172 |
========================= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
173 |
|
2086 | 174 |
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
|
175 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
176 |
$ gradle dependencies |
2086 | 177 |
$ 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
|
178 |
$ 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
|
179 |
$ gradle :$SUBPROJ:dependencies |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
180 |
$ 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
|
181 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
182 |
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
|
183 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
184 |
$ gradle buildEnvironment |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
185 |
$ 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
|
186 |
$ gradle :$SUBPROJ:buildEnvironment |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
187 |
|
2086 | 188 |
Paths to dependencies can be printed via task:: |
189 |
||
190 |
task printDepPaths { |
|
191 |
doLast { configurations.runtime.each { println it } } |
|
192 |
} |
|
193 |
||
194 |
All dependencies can be copied to single directory via task:: |
|
195 |
||
196 |
task copyRuntimeLibs(type: Copy) { |
|
197 |
into "lib" |
|
198 |
from configurations.runtime |
|
199 |
// from configurations.testRuntime - configurations.runtime |
|
200 |
} |
|
201 |
||
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
202 |
List project properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
203 |
======================= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
204 |
:: |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
205 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
206 |
$ gradle properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
207 |
$ gradle :$SUBPROJ:properties |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
208 |
$ 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
|
209 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
210 |
Dry tun |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
211 |
======= |
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
212 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
213 |
``-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
|
214 |
|
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
215 |
$ 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
|
216 |
|
2158
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
217 |
Bootstrap project structure |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
218 |
=========================== |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
219 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
220 |
This creates simple project with Gradle boilerplate files:: |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
221 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
222 |
$ gradle init --type java-library |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
223 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
224 |
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
|
225 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
226 |
$ gradle init --type pom |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
227 |
|
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
228 |
https://docs.gradle.org/current/userguide/build_init_plugin.html |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
229 |
Official docs on ``init`` plugin. |
4273aeaa0c1a
Bootstrap project structure.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2157
diff
changeset
|
230 |
|
2157 | 231 |
Gradle wrapper |
232 |
============== |
|
233 |
||
234 |
With Gradle v2.4 and above:: |
|
235 |
||
236 |
$ cd $PROJ |
|
237 |
$ gradle wrapper --gradle-version 3.5 |
|
238 |
||
239 |
It will add ``gradle/wrapper/gradle-wrapper.jar`` to project root and next call |
|
240 |
to ``./gradlew`` download Gradle distribution from ``distributionUrl`` parameter |
|
241 |
from ``gradle/wrapper/gradle-wrapper.properties`` file. Dictribution will be |
|
242 |
cached in ``~/.gradle/wrapper/dists.gradle/wrapper/dists`` directory so next |
|
243 |
calls won't require download. |
|
244 |
||
245 |
Alternatively define task:: |
|
246 |
||
247 |
task wrapper(type: Wrapper) { |
|
248 |
gradleVersion = '2.0' |
|
249 |
} |
|
250 |
||
251 |
For increase security add ``distributionSha256Sum`` parameter to |
|
252 |
``gradle-wrapper.properties`` file. Distribution SHA-256 sum can be obtained via |
|
253 |
``shasum`` utility. |
|
254 |
||
255 |
https://docs.gradle.org/current/userguide/gradle_wrapper.html |
|
256 |
Official docs. |
|
257 |
||
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
258 |
Managing Gradle cache |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
259 |
===================== |
2083
75ae6a4ad500
Getting list of supported tasks. List project dependencies. List project properties.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2078
diff
changeset
|
260 |
|
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
261 |
Work in offline mode with ``--offline`` option. |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
262 |
|
2120 | 263 |
Invalidate cache (force re-downloading dependencies) with |
264 |
``--refresh-dependencies`` option. |
|
2108
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
265 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
266 |
Alternatively remove ``~/.m2/repository/`` and ``~/.gradle/caches`` directories. |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
267 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
268 |
Gradle cached modules declared as *changing*:: |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
269 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
270 |
dependencies { |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
271 |
compile("com.evil:evil-api:1.0.1-SNAPSHOT") { changing=true } |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
272 |
} |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
273 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
274 |
Default timeout is 24 hours and can be reset/changed via:: |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
275 |
|
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
276 |
configurations.all { |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
277 |
resolutionStrategy.cacheChangingModulesFor 0, 'seconds' |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
278 |
} |
651a45561a46
Managing Gradle cache.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2104
diff
changeset
|
279 |
|
2117
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
280 |
Download sources and javadoc of dependencies |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
281 |
============================================ |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
282 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
283 |
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
|
284 |
``idea`` plugin to your ``build.gradle``:: |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
285 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
286 |
apply plugin: 'idea' |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
287 |
idea.module.downloadJavadoc = true |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
288 |
idea.module.downloadSources = true |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
289 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
290 |
and invoke plugin:: |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
291 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
292 |
$ gradle idea |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
293 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
294 |
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
|
295 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
296 |
$ gradle cleanIdea |
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
297 |
|
22f21cc41569
Download sources and javadoc of dependencies.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2108
diff
changeset
|
298 |