Skip to content

Commit

Permalink
1. support for #37 - preserve the local db
Browse files Browse the repository at this point in the history
2. provide descriptions for gradle tasks
  • Loading branch information
kdabir committed Feb 4, 2017
1 parent 06ec27b commit 40baf31
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ test:
p:
./gradlew --configure-on-demand glide-gradle-plugin:jWL && ./gradlew --stop

l:
./gradlew --configure-on-demand glide-gradle-plugin:pTML

si:
./gradlew --configure-on-demand sandbox:glideInfo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GlideGradlePlugin implements Plugin<Project> {
}

if (project.gradle.startParameter.continuous) {
project.logger.debug('we are in continuous mode')
project.logger.info('we are in continuous mode')
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ class GlideExtension {
String env

// Experimental feature
boolean daemon = true
boolean daemon = false

/**
* the file representing the local db
*/
File localDbFile

GlideExtension(Project project, Properties defaultVersions) {
this.project = project
localDbFile = project.file(".db/local_db.bin")
versions = new VersionsExtension(defaultVersions)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,23 @@ class AfterEvaluateProjectConfigurator extends ProjectDecorator {
// this may not be required as we are overriding explodedAppDirectory below
warDir = this.warRoot

// daemon = true
// oauth2 is sorta mandatory now
appCfg.oauth2 = true

// instead of this, user can control via appengine extension itself
// daemon = this.configuredGlideExtension.daemon

// TODO add following only if we want to reload classes
jvmFlags += ["-Dappengine.fullscan.seconds=${syncFrequency}",
"-Ddatastore.backing_store=../../.local.db.bin"]
jvmFlags += ["-Dappengine.fullscan.seconds=${this.syncFrequency}",
"-Ddatastore.backing_store=${this.configuredGlideExtension.localDbFile.absolutePath}"]
}
}
}

private void configureGlideTasks() {
project.tasks.withType(GlideSetup) { GlideSetup task ->
task.webInfDir = this.webInfDir
task.localDbFile = this.configuredGlideExtension.localDbFile
}

project.tasks.getByName(GlideTaskCreator.GLIDE_COPY_LIBS_TASK_NAME).with {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
package glide.gradle.project.decorators

import com.google.appengine.AppEnginePlugin
import glide.gradle.tasks.ForgivingSync
import glide.gradle.tasks.GlideGenerateConf
import glide.gradle.tasks.GlideInfo
import glide.gradle.tasks.GlideSetup
import glide.gradle.tasks.GlideStartSync
import glide.gradle.tasks.GlideSyncOnce
import glide.gradle.tasks.*
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.Copy
Expand Down Expand Up @@ -44,13 +39,26 @@ class GlideTaskCreator extends ProjectDecorator {

def createAndConfigureGlideTasks() {
// Create Task objects
GlideSetup glideSetupDir = createGlideTask(GLIDE_SETUP_TASK_NAME, GlideSetup)
GlideInfo glideInfo = createGlideTask(GLIDE_INFO_TASK_NAME, GlideInfo)
Copy glideCopyLibs = createGlideTask(GLIDE_COPY_LIBS_TASK_NAME, Copy)
GlideGenerateConf glideGenerateConf = createGlideTask(GLIDE_GENERATE_CONFIG_TASK_NAME, GlideGenerateConf)
ForgivingSync glideAppSync = createGlideTask(GLIDE_APP_SYNC_TASK_NAME, ForgivingSync)
GlideStartSync glideStartSync = createGlideTask(GLIDE_START_SYNC_TASK_NAME, GlideStartSync)
GlideSyncOnce glideSyncOnce = createGlideTask(GLIDE_SYNC_ONCE_TASK_NAME, GlideSyncOnce)
GlideSetup glideSetupDir = createGlideTask(GLIDE_SETUP_TASK_NAME, GlideSetup,
"Creates output directory")

Copy glideCopyLibs = createGlideTask(GLIDE_COPY_LIBS_TASK_NAME, Copy,
"Copies the dependency jar files to output dir")

GlideGenerateConf glideGenerateConf = createGlideTask(GLIDE_GENERATE_CONFIG_TASK_NAME, GlideGenerateConf,
"Generates config files required for app engine web application in output dir")

ForgivingSync glideAppSync = createGlideTask(GLIDE_APP_SYNC_TASK_NAME, ForgivingSync,
"Sync app changes to output dir, useful in continuous mode")


GlideStartSync glideStartSync = createGlideTask(GLIDE_START_SYNC_TASK_NAME, GlideStartSync,
"Starts syncing changes from app dir to output dir, also generates config if required (only useful in run mode)")

GlideSyncOnce glideSyncOnce = createGlideTask(GLIDE_SYNC_ONCE_TASK_NAME, GlideSyncOnce,
"Syncs changes from app dir to output dir, also generates config if required")

Task glidePrepare = createGlideTask(GLIDE_PREPARE_TASK_NAME, Task)
// Task glideRunWithSync = createGlideTask('glideRunWithSync', Task)
// Task glideRunWithoutSync = createGlideTask('glideRunWithoutSync', Task)
Expand All @@ -71,9 +79,11 @@ class GlideTaskCreator extends ProjectDecorator {

}

public <T extends Task> T createGlideTask(String taskName, Class<T> taskClass) {
public <T extends Task> T createGlideTask(String taskName, Class<T> taskClass, String description = null) {
Task createdTask = this.project.tasks.create(taskName, taskClass)
createdTask.group = GLIDE_TASK_GROUP_NAME
if (description)
createdTask.description = description
return createdTask
}

Expand Down
2 changes: 2 additions & 0 deletions glide-gradle-plugin/src/glide/gradle/tasks/GlideInfo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.gradle.api.tasks.TaskAction
@ParallelizableTask
class GlideInfo extends DefaultTask {

String description = "Prints the version"

@TaskAction
def print() {
def selfVersion = DefaultVersions.get().selfVersion
Expand Down
2 changes: 2 additions & 0 deletions glide-gradle-plugin/src/glide/gradle/tasks/GlideSetup.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import org.gradle.api.tasks.TaskAction
class GlideSetup extends DefaultTask {

File webInfDir // not marking as input, don't need to perform any computation
File localDbFile

@TaskAction
protected void prepare() {
webInfDir?.mkdirs()
localDbFile.parentFile.mkdirs()
}
}

0 comments on commit 40baf31

Please sign in to comment.