Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Adding support for a gradle multi-project build #696

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
.sass-cache
node_modules
npm-debug.log
.gradle/
.project
.classpath
build/
.settings/
4 changes: 2 additions & 2 deletions README-JavaScript.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ This README focuses on the developer automation for JavaScript development that

To configure and develop the browser app for Samplestack, you need the following software:

* Node.js, version 0.10.x (it is mot yet compatible with Node.js 0.11 or 0.12). See [nodejs.org](http://nodejs.org).
* npm, version 2.1.1 or higher. See [npmjs.com](https://www.npmjs.com/)
* Node.js, version 0.10.33 or higher. See [nodejs.org](http://nodejs.org).
* npm, version 2.1.12 or higher. See [npmjs.com](https://www.npmjs.com/)
* git. See [git-scm.com](http://git-scm.com/)

This is "tech-stack" or minor variants thereof are almost ubiquitous in JavaScript dwvelopment shops in 2015.
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ REMEMBER to change the branch name in this code when preparing releases

> Samplestack is a comprehensive sample application that demonstrates how to build an effective MarkLogic application. Based on the idea of a "Question and Answer" website, Samplestack shows you how to integrate MarkLogic into a three-tier application architecture (browser, application server, and database).

## README for Version 1.1.0
## README for Version 1.2.0

This release features two middle tiers

- one for the Java enterprise developer, implemented using Java, Spring and Gradle
- one for the JavaScript developer, imple,emted using JavaScript, Node.js and Gulp.
- one for the JavaScript developer, implemented using JavaScript, Node.js and Gulp.

The project includes the following major components:
* [MarkLogic](http://www.marklogic.com/) for the database tier
* MVC browser application implemented in [Angular.js](https://angularjs.org)
* Middle-tier REST server implemented in Java/[Spring](http://projects.spring.io/spring-framework/)
* [Gradle](http://www.gradle.org/) framework to drive build and configuration of the appserver and database tiers in Java/Groovy
* [ml-grade](https://github.com/rjrudin/ml-gradle) Gradle plugin that supports a number of tasks pertaining to deploying an application to MarkLogic and interacting with other features of MarkLogic via a Gradle build file.
* Middle-tier REST server implemented in Node.js/[Express](expressjs.com)
* [Gulp](http://www.gradle.org/)-based automation to drive build and configuration of Javascript and database tiers (**note: database-tier Gulp-based setup coming soon**)
* Unit and end-to-end tests
Expand Down
1 change: 1 addition & 0 deletions appserver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
22 changes: 10 additions & 12 deletions appserver/java-spring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The implementation of samplestack that runs using
* gradle as build tool
* Java as middle-tier development language
* Spring Boot as application framework
* MarkLogic as database tier
* MarkLogic as database tier (and [ml-gradle](https://github.com/rjrudin/ml-gradle) as the MarkLogic-specific bulid tool)

This README covers running samplestack quickly, then documents each of the commands
available to the Java developer as she iterates through code exploration.
Expand All @@ -16,7 +16,7 @@ available to the Java developer as she iterates through code exploration.

*To build and run:*

Before running anything here, you need MarkLogic 8.0-1.1, installed and
Before running anything here, you need MarkLogic 8.0-1.1 or later, installed and
running. Start this quickstart with it installed and running. By default this
process will will secure MarkLogic with username admin, password admin. If you
have already secured MarkLogic, you need to update gradle.properties with the
Expand Down Expand Up @@ -57,21 +57,17 @@ Its possible that you will need to clean your environment, especially if you're

`./gradlew --stop` (if you've been using the gradle daemon.)
`./gradlew clean`
`./gradlew dbteardown`
`./gradlew undeploy` (an ml-gradle task)

*gradle tasks used in Samplestack development*
*other gradle tasks used in Samplestack development*

* `./gradlew dbInit` This is the task that initializes a MarkLogic server and preps it for runninng Samplestack. It is a one-time task; after running, the users, roles, database, and REST server will be available for configuration.
* `./gradlew dbTeardown` This command removes Samplestack's entire REST server, database, and security objects from the MarkLogic server.
* `./gradlew mlInit` (an ml-gradle task) This is the task that initializes a MarkLogic server and preps it for runninng Samplestack. It is a one-time task; after running, the users, roles, database, and REST server will be available for configuration.
* `./gradlew mlUndeploy` (an ml-gradle task) This command removes Samplestack's entire REST server, database, and security objects from the MarkLogic server.

* `./gradlew clean` This built-in gradle task cleans the build directory. When in doubt, try it.
* `./gradlew assemble` This command bootstraps the middle tier, runs tests, and builds the Java project. When it is done you have verified the unit tests and built samplestack.
* `./gradlew tasks` Lists tasks available to the samplestack project.

* `./gradlew dbConfigure` Incrementally applies configuration changes in ../../database/* to the MarkLogic instance.
* `./gradlew dbConfigureClean` Removes cache info for configuration from build direcotiry (so next dbConfigure will process all files).
* `./gradlew dbConfigureAll` dbConfigureClean then runs dbConfigure. Uploads all config files to MarkLogic.

* `./gradlew bootRun` This command runs the middle tier and MarkLogic services. This project also contains a built version of the front-end angular application. If you want to use and exercise the front-end independently, see the sibling project in /browser for instructions on running the browser application
* `./gradlew seedDataFetch` Fetches seed data from a remote location to the build directory.
* `./gradlew seedDataExtract` Extracts the fetched seed data tgz to within the directory.
Expand All @@ -86,12 +82,14 @@ Its possible that you will need to clean your environment, especially if you're
* `./gradlew dbTest` This command runs the unit tests for server extensions.
* `./gradlew integrationTest` This command runs the tests that exercise the whole middle and database tier apparatus.

In previous releases of Samplestack, the tasks `dbConfigure`, `dbConfigure` and `dbConfigureAll` were present, allowing for incrementally
applying configuration and re-applying configuration. Those tasks are no longer included -- however, similar functionality is exposed by ml-gradle
and may be used in Samplestack, as well (e.g. `mlClearModules`, `mlLoadModules`. **Documentation of each task that ml-gradle supports is beyond the scope of this document. Please see the [ml-gradle documentation](https://github.com/rjrudin/ml-gradle) for more information.**

*To use with Eclipse*

See project wiki https://github.com/marklogic/marklogic-samplestack/wiki/Getting-Started-in-Eclipse



### Endpoints

Here are the endpoints supported by the middle tier appserver:
Expand Down
101 changes: 9 additions & 92 deletions appserver/java-spring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ buildscript {
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.spring.io/milestone" }
jcenter()

maven {url "http://developer.marklogic.com/maven2/"}
maven {url "http://rjrudin.github.io/marklogic-java/releases"}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
Expand All @@ -24,100 +27,17 @@ buildscript {

/* plugins */
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'


group = samplestackGroup
version = samplestackVersion
sourceCompatibility = samplestackSourceCompatibility

/*
* INIT
* Run this task to initialize a fresh MarkLogic server
* and install security objects.
*/
task dbInit(type: MarkLogicInitTask)
dbInit.roles = file("../../database/security/roles")
dbInit.users = file("../../database/security/users")

/*
* TEARDOWN
* This task removes all trace of samplestack
*/
task dbTeardown(type: MarkLogicTeardownTask)

/*
* CONFIGURE
*
* This task configures the database and REST API instance
* based on files in the database directory
*/
task dbConfigure(type: MarkLogicConfigureTask)

task dbConfigureClean << {
delete("${buildDir}/database")
}


dbConfigure.inputDir = file('../../database')
dbConfigure.outputDir = file("${buildDir}/database")
dbConfigure.inputProperty = project.properties['taskInputProperty'] ?: "original"
dbConfigure.shouldRunAfter dbInit
dbConfigure.shouldRunAfter dbConfigureClean
dbInit.dependsOn(dbConfigureClean)

task dbConfigureAll
dbConfigureAll.dependsOn dbConfigureClean
dbConfigureAll.dependsOn dbConfigure

/**
* ASSEMBLE
*/
assemble.dependsOn(dbInit, dbConfigure, test)

/**
* FETCH SEED DATA
*/
task seedDataFetch(type: MarkLogicFetchTask) {
url = project.hasProperty("seedDataUrl") ? project.seedDataUrl : "http://developer.marklogic.com/media/gh/seed-data1.8.2.tgz"
destFile = file("${buildDir}/seed.tgz")
}
seedDataFetch.dependsOn(processResources)

task seedDataExtract {
ext.destDir = file("${buildDir}/seed-data")
ext.srcFile = file("${buildDir}/seed.tgz")
inputs.file srcFile
outputs.dir destDir
doLast {
destDir.mkdirs()
copy {
from tarTree(resources.gzip(srcFile))
into destDir
}
}
}
seedDataExtract.dependsOn(seedDataFetch)

/*
* LOAD
*/
task dbLoad(type: MarkLogicSlurpTask) {
seedDirectory = file("${buildDir}/seed-data")
inputs.dir seedDirectory
}
dbLoad.mustRunAfter(assemble)
dbLoad.dependsOn(seedDataExtract)
/* never skip dbload if requested */
dbLoad.outputs.upToDateWhen { false }

/*
* CLEAR
*/
task dbClear(type: MarkLogicClearTask)

assemble.dependsOn(":database:mlDeploy")

/* use same properties for gradle and Java runtime */
task props(type: Copy) {
Expand All @@ -135,8 +55,9 @@ task appserver <<
{
println "Bootstrapping, seeding and starting Samplestack appserver"
}
appserver.dependsOn(clean, assemble, dbLoad, bootRun)
bootRun.shouldRunAfter(dbLoad)
appserver.dependsOn(clean, ":appserver:java-spring:assemble", ":database:dbLoad", bootRun)
bootRun.shouldRunAfter(":database:dbLoad")


/* The code repositories to consult for dependencies */
repositories {
Expand Down Expand Up @@ -173,7 +94,7 @@ task unitTest(type: Test) {
}
}

test.dependsOn(props, dbConfigure)
test.dependsOn(props, ":database:mlLoadModules")

task dbTest(type: Test) {
useJUnit {
Expand All @@ -187,7 +108,3 @@ task integrationTest(type: Test) {
}
}

/* task to generate the gradle wrapper script */
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
18 changes: 0 additions & 18 deletions appserver/java-spring/buildSrc/build.gradle

This file was deleted.

This file was deleted.

Loading