document gradle
more/packages/gradle.scm
| 30 | 30 | #:use-module (more packages java) | |
| 31 | 31 | #:use-module (more packages maven)) | |
| 32 | 32 | ||
| 33 | + | ;; Gradle requires guava@17. | |
| 34 | + | ;; TODO: patch gradle to support at least guava@20 and send it upstream. | |
| 33 | 35 | (define-public java-guava-for-gradle | |
| 34 | 36 | (package | |
| 35 | 37 | (inherit java-guava) | |
… | |||
| 47 | 49 | #:tests? #f)))); Not in a "java" subdirectory | |
| 48 | 50 | ||
| 49 | 51 | (define (gradle-subproject subproject projects runtime) | |
| 52 | + | "Gradle is made of a lot of subprojects. Each subproject can be compiled in | |
| 53 | + | a certain order and in the same way. | |
| 54 | + | ||
| 55 | + | This procedure builds the java source of @code{subproject}. | |
| 56 | + | ||
| 57 | + | Each subproject contains at least a text file, gradle-*-classpath.properties | |
| 58 | + | that contain dependency information. This file is created using the | |
| 59 | + | @code{projects} and @code{runtime} parameters." | |
| 50 | 60 | (package | |
| 51 | 61 | (name (string-append "gradle-" subproject)) | |
| 52 | 62 | (version "4.4.0") | |
… | |||
| 63 | 73 | "gradle-match-files-witouht-version-number.patch")))) | |
| 64 | 74 | (build-system ant-build-system) | |
| 65 | 75 | (arguments | |
| 76 | + | ;; The jar-name must be this exactly: gradle will not find its jar files | |
| 77 | + | ;; if they are named differently. | |
| 66 | 78 | `(#:jar-name (string-append "gradle-" ,subproject "-4.4.jar") | |
| 67 | 79 | #:source-dir (string-append "subprojects/" ,subproject "/src/main/java") | |
| 68 | 80 | #:jdk ,icedtea-8 | |
… | |||
| 72 | 84 | (modify-phases %standard-phases | |
| 73 | 85 | (add-before 'build 'add-implementation-info | |
| 74 | 86 | (lambda _ | |
| 87 | + | ;; Add implementation information to the MANIFEST.MF file. We can | |
| 88 | + | ;; substitute this in the manifest phase. | |
| 75 | 89 | (substitute* "build.xml" | |
| 76 | 90 | (("message=\"") | |
| 77 | 91 | (string-append "message=\"Implementation-Title: Gradle" | |
… | |||
| 82 | 96 | (add-before 'build 'add-properties | |
| 83 | 97 | (lambda* (#:key inputs #:allow-other-keys) | |
| 84 | 98 | (mkdir-p "build/classes") | |
| 99 | + | ;; This file contains dependency information. | |
| 100 | + | ;; The projects list is a list of gradle-subprojects that this | |
| 101 | + | ;; subproject depends directly on at runtime. This information | |
| 102 | + | ;; can be found in the *.gradle file in the subproject's directory. | |
| 103 | + | ;; | |
| 104 | + | ;; The runtime list is a list of external projects this subproject | |
| 105 | + | ;; depends on. This list must be a list of jar files, so we transform | |
| 106 | + | ;; the project name into a list of jar files the package contains. | |
| 107 | + | ;; This information can also be found in the *.gradle file of the | |
| 108 | + | ;; subproject. | |
| 85 | 109 | (with-output-to-file (string-append "build/classes/gradle-" | |
| 86 | 110 | ,subproject | |
| 87 | 111 | "-classpath.properties") | |
… | |||
| 98 | 122 | #t)) | |
| 99 | 123 | (add-before 'build 'copy-resources | |
| 100 | 124 | (lambda _ | |
| 125 | + | ;; If the subproject has a resources directory, copy it to the jar | |
| 126 | + | ;; file. | |
| 101 | 127 | (let ((resources (string-append "subprojects/" ,subproject | |
| 102 | 128 | "/src/main/resources"))) | |
| 103 | - | (if (file-exists? resources) | |
| 104 | - | (copy-recursively resources "build/classes")))))))) | |
| 129 | + | (if (file-exists? resources) | |
| 130 | + | (copy-recursively resources "build/classes")))))))) | |
| 105 | 131 | (inputs '()) | |
| 106 | 132 | (native-inputs '()) | |
| 107 | 133 | (home-page "") | |
… | |||
| 110 | 136 | (license license:asl2.0))) | |
| 111 | 137 | ||
| 112 | 138 | (define (gradle-groovy-subproject subproject projects runtime) | |
| 139 | + | "This procedure is similar to @code{gradle-groovy-subproject}, but it | |
| 140 | + | builds a module containing groovy source code." | |
| 113 | 141 | (let ((base (gradle-subproject subproject projects runtime))) | |
| 114 | 142 | (package | |
| 115 | 143 | (inherit base) | |
… | |||
| 122 | 150 | (add-before 'build 'use-groovy | |
| 123 | 151 | (lambda _ | |
| 124 | 152 | (substitute* "build.xml" | |
| 153 | + | ;; Change the compiler to groovyc | |
| 125 | 154 | (("javac") "groovyc") | |
| 155 | + | ;; Make it fork | |
| 126 | 156 | (("includeantruntime=\"false\"") | |
| 127 | 157 | "includeantruntime=\"false\" fork=\"yes\"") | |
| 158 | + | ;; groovyc doesn't understand the --classpath argument (bug?) | |
| 128 | 159 | (("classpath=\"@refidclasspath\"") | |
| 129 | 160 | "classpathref=\"classpath\"") | |
| 130 | 161 | ;; To enable joint compilation | |
| 131 | 162 | (("classpathref=\"classpath\" />") | |
| 132 | 163 | "classpathref=\"classpath\"><javac source=\"1.5\" target=\"1.5\" /></groovyc>") | |
| 164 | + | ;; Actually create a definition of the groovyc task. | |
| 165 | + | ;; FIXME: Can't we use groovy-ant for that? | |
| 133 | 166 | (("<project basedir=\".\">") | |
| 134 | 167 | "<project basedir=\".\"><taskdef name=\"groovyc\" | |
| 135 | 168 | classname=\"org.codehaus.groovy.ant.Groovyc\" />")))))))) | |
… | |||
| 137 | 170 | `(("groovy" ,groovy) | |
| 138 | 171 | ,@(package-inputs groovy)))))) | |
| 139 | 172 | ||
| 173 | + | ;; This gradle plugin is not a subproject, but it is required by buildsrc. | |
| 140 | 174 | (define-public gradle-japicmp-plugin | |
| 141 | 175 | (package | |
| 142 | 176 | (name "gradle-japicmp-plugin") | |
… | |||
| 175 | 209 | (description "") | |
| 176 | 210 | (license license:asl2.0))) | |
| 177 | 211 | ||
| 212 | + | ;; This package is not meant to be available at runtime: it a build dependency | |
| 213 | + | ;; only. It contains task definitions used to build submodules. Unfortunately, | |
| 214 | + | ;; it depends on many subprojects at runtime, and cannot be used without a | |
| 215 | + | ;; complete gradle. | |
| 178 | 216 | (define-public gradle-buildsrc | |
| 179 | 217 | (package | |
| 180 | 218 | (inherit (gradle-subproject "buildsrc" '() '())) | |
… | |||
| 1164 | 1202 | ||
| 1165 | 1203 | ;; This package doesn't work. I need to understand how api-mapping.txt and | |
| 1166 | 1204 | ;; default-imports.txt are generated. Currently they are generated by a custom | |
| 1167 | - | ;; task that is run by gradle, but we don't have enough of gradle to run that. | |
| 1205 | + | ;; task defined in buildsrc that is run by gradle, but we don't have enough of | |
| 1206 | + | ;; gradle to run that. | |
| 1168 | 1207 | (define-public gradle-docs | |
| 1169 | 1208 | (let ((base (gradle-subproject "docs" '() '()))) | |
| 1170 | 1209 | (package | |
… | |||
| 1185 | 1224 | (format #t ""))) | |
| 1186 | 1225 | (zero? (system* "ant" "jar"))))))))))) | |
| 1187 | 1226 | ||
| 1227 | + | ;; Gradle doesn't provide a gradle binary or script, so we provide it instead. | |
| 1228 | + | ;; Gradle expects that all its modules and dependency jars are located in the | |
| 1229 | + | ;; same directory. That directory must be called "lib". | |
| 1230 | + | ;; In this package, we create a script that puts gradle-launcher in the | |
| 1231 | + | ;; classpath (that's ok because gradle-launcher has a Class-Path declaration in | |
| 1232 | + | ;; its MANIFEST.MF). This runs the main entry point of gradle that will look | |
| 1233 | + | ;; for its requirements in that directory. I don't really understand how this | |
| 1234 | + | ;; is done, since the classpath contains only jar files and not directories, | |
| 1235 | + | ;; and it seems to look for gradle-installation-beacon, but it's definitely not | |
| 1236 | + | ;; in the classpath... | |
| 1237 | + | ;; | |
| 1238 | + | ;; Currently, gradle can find its modules and start running, but it will fail | |
| 1239 | + | ;; at reading the api-mapping.txt file from gradle-docs. | |
| 1188 | 1240 | (define-public gradle | |
| 1189 | 1241 | (package | |
| 1190 | 1242 | (inherit gradle-base-services) | |
… | |||
| 1260 | 1312 | "/bin/java") | |
| 1261 | 1313 | (string-append libdir "/gradle-launcher-4.4.jar")))) | |
| 1262 | 1314 | (chmod filename #o755) | |
| 1315 | + | ;; Create a symlink for every dependency listed above. | |
| 1263 | 1316 | (for-each | |
| 1264 | 1317 | (lambda (lib) | |
| 1265 | 1318 | (symlink lib (string-append libdir "/" (basename lib)))) | |
… | |||
| 1269 | 1322 | (find-files (assoc-ref %build-inputs lib) | |
| 1270 | 1323 | ".*.jar")) | |
| 1271 | 1324 | dependencies))) | |
| 1325 | + | ;; Using a symlink for gradle-launcher doesn't seem to work. | |
| 1272 | 1326 | (delete-file (string-append libdir "/gradle-launcher-4.4.jar")) | |
| 1273 | 1327 | (copy-file (string-append (assoc-ref %build-inputs "gradle-launcher") | |
| 1274 | 1328 | "/share/java/gradle-launcher-4.4.jar") | |