|
1 | 1 | plugins { |
2 | | - id 'java' //optional - delete if not needed |
3 | | - id 'net.saliman.properties' version '1.4.6' |
4 | | - id 'com.marklogic.ml-gradle' version '3.7.1' |
| 2 | + id 'java' //optional - delete if not needed |
| 3 | + id 'net.saliman.properties' version '1.4.6' |
| 4 | + id 'com.marklogic.ml-gradle' version '3.7.1' |
5 | 5 | } |
6 | 6 |
|
7 | 7 | repositories { |
8 | | - // To use gradle in disconnected mode, you just need to set the 'disconnected' property. E.g. gradle compileJava -Pdisconnected |
9 | | - if ( project.hasProperty("disconnected") && !"FALSE".equalsIgnoreCase(disconnected)) { |
10 | | - println "Using offline repositories" |
11 | | - maven {url uri( projectMavenRepo ) } |
12 | | - } else { |
13 | | - println "Using online repositories" |
14 | | - jcenter() |
15 | | - maven { url "https://developer.marklogic.com/maven2/" } |
16 | | - } |
| 8 | + // To use gradle in disconnected mode, you just need to set the 'disconnected' property. E.g. gradle compileJava -Pdisconnected |
| 9 | + if (project.hasProperty("disconnected") && !"FALSE".equalsIgnoreCase(disconnected)) { |
| 10 | + println "Using offline repositories" |
| 11 | + maven { url uri(projectMavenRepo) } |
| 12 | + } else { |
| 13 | + println "Using online repositories" |
| 14 | + jcenter() |
| 15 | + maven { url "https://developer.marklogic.com/maven2/" } |
| 16 | + } |
17 | 17 | } |
18 | 18 |
|
19 | 19 | configurations { |
20 | 20 | mlcp //example if you want to use mlcp. Delete otherwise |
21 | 21 | } |
22 | 22 |
|
23 | 23 | dependencies { |
24 | | - // sample java compile dependency. Remove if not required |
25 | | - compile 'com.marklogic:marklogic-xcc:9.0.4' |
| 24 | + // sample java compile dependency. Remove if not required |
| 25 | + compile 'com.marklogic:marklogic-xcc:9.0.4' |
26 | 26 |
|
27 | | - //sample mlcp dependency. Remove if not required |
28 | | - mlcp "com.marklogic:mlcp:9.0.5" |
| 27 | + //sample mlcp dependency. Remove if not required |
| 28 | + mlcp "com.marklogic:mlcp:9.0.5" |
29 | 29 | } |
30 | 30 |
|
31 | | - |
32 | | - |
33 | 31 | /** |
34 | 32 | * START: Disconnected gradle tasks |
35 | 33 | */ |
36 | 34 | gradle.taskGraph.whenReady { graph -> |
37 | | - if (graph.hasTask(downloadToProjectMavenRepo)) { |
38 | | - println project.gradle.gradleUserHomeDir |
39 | | - if (!project.gradle.gradleUserHomeDir.equals(new File(rootDir,projectGradleHome))) { |
40 | | - throw new GradleException("Please set the gradle user home property to $projectGradleHome on the gradle command line - e.g. \n " + |
41 | | - (System.getProperty("os.name").startsWith("Windows") ? "" : "./") + |
42 | | - "gradlew -Dgradle.user.home=$projectGradleHome <task_to_execute>") |
43 | | - } |
44 | | - } |
| 35 | + if (graph.hasTask(downloadToProjectMavenRepo)) { |
| 36 | + println project.gradle.gradleUserHomeDir |
| 37 | + if (!project.gradle.gradleUserHomeDir.equals(new File(rootDir, projectGradleHome))) { |
| 38 | + throw new GradleException("Please set the gradle user home property to $projectGradleHome on the gradle command line - e.g. \n " + |
| 39 | + (System.getProperty("os.name").startsWith("Windows") ? "" : "./") + |
| 40 | + "gradlew -Dgradle.user.home=$projectGradleHome <task_to_execute>") |
| 41 | + } |
| 42 | + } |
45 | 43 | } |
46 | 44 |
|
47 | 45 | task downloadToProjectMavenRepo(type: Copy) { |
48 | | - /* |
49 | | - * Include any configuration dependencies here that you want to copy the dependencies for. |
50 | | - * These are defined in the 'dependencies' block. E.g. you need to include |
51 | | - * configurations.compile.files if you want your java 'compile' dependencies downloaded |
52 | | - */ |
53 | | - configurations.compile.files //includes 'java' compile dependencies. Remove if not needed |
54 | | - configurations.mlcp.files //includes 'mlcp' dependencies. Remove if not needed |
55 | | - |
56 | | - from new File(gradle.gradleUserHomeDir, 'caches/modules-2/files-2.1') // correct as of gradle 4.7 |
57 | | - into new File(rootDir, projectMavenRepo) |
58 | | - eachFile { |
59 | | - List<String> parts = it.path.split('/') |
60 | | - it.path = (parts[0].replace('.','/') + '/' + parts[1]) + '/' + parts[2] + '/' + parts[4] |
61 | | - } |
62 | | - includeEmptyDirs false |
| 46 | + /* |
| 47 | + * Include any configuration dependencies here that you want to copy the dependencies for. |
| 48 | + * These are defined in the 'dependencies' block. E.g. you need to include |
| 49 | + * configurations.compile.files if you want your java 'compile' dependencies downloaded |
| 50 | + */ |
| 51 | + configurations.compile.files //includes 'java' compile dependencies. Remove if not needed |
| 52 | + configurations.mlcp.files //includes 'mlcp' dependencies. Remove if not needed |
| 53 | + |
| 54 | + from new File(gradle.gradleUserHomeDir, 'caches/modules-2/files-2.1') // correct as of gradle 4.7 |
| 55 | + into new File(rootDir, projectMavenRepo) |
| 56 | + eachFile { |
| 57 | + List<String> parts = it.path.split('/') |
| 58 | + it.path = (parts[0].replace('.', '/') + '/' + parts[1]) + '/' + parts[2] + '/' + parts[4] |
| 59 | + } |
| 60 | + includeEmptyDirs false |
63 | 61 | } |
64 | 62 |
|
65 | 63 | task makeOfflineZip(type: Zip, dependsOn: downloadToProjectMavenRepo) { |
66 | | - from rootDir |
67 | | - excludes = ['.tmp','.gradle','build/gradle-home','build/distributions','build/offline/gradle/wrapper/dists'] |
68 | | - destinationDir(file('build/distributions')) |
69 | | - archiveName = 'offline.zip' |
70 | | - doLast { |
71 | | - println "Created offline project zip at build/distributions/offline.zip" |
72 | | - } |
| 64 | + from rootDir |
| 65 | + excludes = ['.tmp', '.gradle', 'build/gradle-home', 'build/distributions', 'build/offline/gradle/wrapper/dists'] |
| 66 | + destinationDir(file('build/distributions')) |
| 67 | + archiveName = 'offline.zip' |
| 68 | + doLast { |
| 69 | + println "Created offline project zip at build/distributions/offline.zip" |
| 70 | + } |
73 | 71 | } |
74 | 72 |
|
75 | 73 | /** |
|
0 commit comments