Skip to content

Commit 4e5f559

Browse files
Dermot SmythDermot Smyth
authored andcommitted
removed multiple examples and created just a single one
1 parent 34a1b5a commit 4e5f559

File tree

15 files changed

+386
-326
lines changed

15 files changed

+386
-326
lines changed

examples/disconnected-project-using-plugins-advanced/README.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

examples/disconnected-project-using-plugins-advanced/settings.gradle

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Standalone Gradle deployer with ml-gradle
2+
3+
## Quickstart
4+
5+
Summary of the steps required. See sections below for more detailed steps
6+
7+
*NOTE:* The use of gradlew is required
8+
9+
1. Create standalone deployer zip
10+
```
11+
./gradlew makeOfflineZip
12+
```
13+
2. Copy zip (build/distributions/offline.zip) to desired location / server and unzip
14+
15+
3. Run disconnected tasks from unzip location
16+
```
17+
./gradlew mlDeploy -Pdisconnected=true
18+
```
19+
20+
21+
## Overview
22+
23+
An example of how to create a completely self-contained deployer zip that contains -
24+
1. All of the plugin / depencencies required to run the deployment (including ml-gradle)
25+
2. The gradle distribution
26+
27+
Once the zip has been created, you only need Java to run the deployment tasks
28+
29+
This approach is useful when you need to create a package that does not require any external ressources (e.g. maven/gradle repositories) to perform deployment operations.
30+
31+
## Requirements
32+
33+
* Java 8/9
34+
* Internet connection (for creation of zip only)
35+
36+
37+
## How it works
38+
39+
This project will -
40+
* Download all of the required dependencies (including plugins) into the 'build/offline/maven-repo' directory in the project.
41+
* Download the gradle binary distribution (zip) into the 'build/offline/gradle/wrapper' directory in the project
42+
* Create an offline.zip in build/distributions that contains
43+
* the gradle project itsself
44+
* all of the required depenencies
45+
* the gradle distribution that works with the gradlew executable
46+
47+
48+
## Usage
49+
50+
*NOTE:* It is important to use the gradlew executable as it will download the gradle distribution that will be encorporated into the self-contained deployer zip
51+
52+
## 1. Create the self-contained deployer zip
53+
54+
*NOTE:* This needs to be executed from a machine with access to the internet. It will create the zip at the location build/distributions/offline.zip
55+
56+
#### Linux / Mac
57+
58+
```
59+
./gradlew makeOfflineZip
60+
```
61+
62+
#### Windows
63+
64+
```
65+
gradlew makeOfflineZip
66+
```
67+
68+
69+
## 2. Unzip the distribution
70+
71+
Copy the created offline.zip to the desired location and unzip
72+
73+
```
74+
unzip offline.zip
75+
```
76+
77+
## 3. Execute disconnected the gradle tasks
78+
79+
From the directory that you have unzipped the offline.zip file into
80+
81+
```
82+
./gradlew mlDeploy -Pdisconnected=true
83+
```
84+
85+
This will use the jars that you have already downloaded to 'build/offline/maven-repo'
86+
87+
## Customise
88+
89+
**IMPORTANT**: If you want to include dependencies for a configuration (e.g. compile, runtime, mlcp etc), then you need to modify the 'downloadToProjectMavenRepo' task to include the relevant configuration. E.g. by adding 'configurations.compile.files' to the beginning of the task, all of the dependencies for the 'compile' task will be downloaded.
90+
91+
E.g. (assuming you are using the java plugin), the configuration below will download all the compile and runtime dependencies that you have defined
92+
93+
```
94+
task downloadToProjectMavenRepo(type: Copy) {
95+
configurations.compile.files
96+
configurations.runtime.files
97+
...
98+
```
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
plugins {
2-
id 'java'
2+
id 'java' //optional - delete if not needed
33
id 'net.saliman.properties' version '1.4.6'
4-
id 'com.marklogic.ml-gradle' version '3.6.3'
4+
id 'com.marklogic.ml-gradle' version '3.7.1'
55
}
66

77
repositories {
88
// 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(this.properties['disconnected'])) {
9+
if ( project.hasProperty("disconnected") && !"FALSE".equalsIgnoreCase(disconnected)) {
1010
println "Using offline repositories"
11-
maven {url uri( 'project-maven-repo' ) }
11+
maven {url uri( projectMavenRepo ) }
1212
} else {
1313
println "Using online repositories"
1414
jcenter()
@@ -17,32 +17,29 @@ repositories {
1717
}
1818

1919
configurations {
20-
mlcp
20+
mlcp //example if you want to use mlcp. Delete otherwise
2121
}
2222

2323
dependencies {
24-
// sample java compile dependency
24+
// sample java compile dependency. Remove if not required
2525
compile 'com.marklogic:marklogic-xcc:9.0.4'
2626

27-
//sample mlcp
27+
//sample mlcp dependency. Remove if not required
2828
mlcp "com.marklogic:mlcp:9.0.5"
2929
}
3030

3131

32+
3233
/**
3334
* START: Disconnected gradle tasks
3435
*/
3536
gradle.taskGraph.whenReady { graph ->
36-
if (graph.hasTask(makeOfflineZip)) {
37-
if (!project.gradle.gradleUserHomeDir.equals(new File(rootDir,"project-gradle-cache"))) {
38-
throw new GradleException("Please set the gradle user home property to 'project-gradle-cache' on the gradle command line - e.g. \n " +
39-
"gradle -Dgradle.user.home=project-gradle-cache makeOfflineZip")
40-
}
41-
}
4237
if (graph.hasTask(downloadToProjectMavenRepo)) {
43-
if (!project.gradle.gradleUserHomeDir.equals(new File(rootDir,"project-gradle-cache"))) {
44-
throw new GradleException("Please set the gradle user home property to 'project-gradle-cache' on the gradle command line - e.g. \n " +
45-
"gradle -Dgradle.user.home=project-gradle-cache 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>")
4643
}
4744
}
4845
}
@@ -53,12 +50,11 @@ task downloadToProjectMavenRepo(type: Copy) {
5350
* These are defined in the 'dependencies' block. E.g. you need to include
5451
* configurations.compile.files if you want your java 'compile' dependencies downloaded
5552
*/
56-
//configurations.runtime.files
57-
configurations.compile.files
58-
configurations.mlcp.files
53+
configurations.compile.files //includes 'java' compile dependencies. Remove if not needed
54+
configurations.mlcp.files //includes 'mlcp' dependencies. Remove if not needed
5955

6056
from new File(gradle.gradleUserHomeDir, 'caches/modules-2/files-2.1') // correct as of gradle 4.7
61-
into 'project-maven-repo'
57+
into new File(rootDir, projectMavenRepo)
6258
eachFile {
6359
List<String> parts = it.path.split('/')
6460
it.path = (parts[0].replace('.','/') + '/' + parts[1]) + '/' + parts[2] + '/' + parts[4]
@@ -68,7 +64,7 @@ task downloadToProjectMavenRepo(type: Copy) {
6864

6965
task makeOfflineZip(type: Zip, dependsOn: downloadToProjectMavenRepo) {
7066
from rootDir
71-
excludes = ['.tmp','.gradle','build','project-gradle-cache']
67+
excludes = ['.tmp','.gradle','build/gradle-home','build/distributions','build/offline/gradle/wrapper/dists']
7268
destinationDir(file('build/distributions'))
7369
archiveName = 'offline.zip'
7470
doLast {
@@ -78,4 +74,4 @@ task makeOfflineZip(type: Zip, dependsOn: downloadToProjectMavenRepo) {
7874

7975
/**
8076
* END: Disconnected gradle tasks
81-
*/
77+
*/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
projectMavenRepo=build/offline/maven-repo
2+
# if you change this, you need to modify gradlew and gradlew.bat also
3+
projectGradleHome=build/gradle-home
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=PROJECT
2+
distributionPath=build/offline/gradle/wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
4+
zipStoreBase=PROJECT
5+
zipStorePath=build/offline/gradle/wrapper

0 commit comments

Comments
 (0)