Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Commit

Permalink
Add set_default_version task, update to gradle 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
loosebazooka committed Feb 14, 2016
1 parent 8daf51e commit 8543a34
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ out
/.settings
/.classpath
/.project
gradle.properties
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The App Engine plugin defines the following tasks:
* `appengineRun`: Starts a local development server running your project code. By default the WAR file is created, exploded and used as
web application directory each time you run this task. This behavior can be changed by setting the convention property
`warDir`.
* `appengineSetDefaultVersion` : Sets the default version of the given module based on `appengine-web.xml`.
* `appengineStartBackend`: Sets the backend state to `START`, allowing it to receive HTTP requests. The backend is defined by the project property `backend`.
* `appengineStop`: Stops the local development server.
* `appengineStopBackend`: Sets the backend state to `STOP` and shuts down any running instances. The backend is defined by the project property `backend`.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jar {
}

task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
gradleVersion = '2.10'
}

modifyPom {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 08 15:11:07 PDT 2015
#Thu Feb 11 17:18:58 EST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
10 changes: 3 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ case "`uname`" in
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
Expand All @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Expand Down Expand Up @@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ echo location of your Java installation.
goto fail

:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
Expand Down
12 changes: 6 additions & 6 deletions scripts/builder-model-impl.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
apply from: 'scripts/java6-mode.gradle'

sourceSets {
model
builderModel
main {
compileClasspath += model.output
runtimeClasspath += model.output
compileClasspath += builderModel.output
runtimeClasspath += builderModel.output
}
}

setJava6Mode(compileModelJava)
setJava6Mode(compileBuilderModelJava)

dependencies {
modelCompile project(':builder-model')
builderModelCompile project(':builder-model')
}

jar {
from {
sourceSets.model.output
sourceSets.builderModel.output
}
}
30 changes: 16 additions & 14 deletions src/main/groovy/com/google/appengine/AppEnginePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME
*/
class AppEnginePlugin implements Plugin<Project> {

// TODO: eclipse plugin integration has special code for v2.3, fix it when ready
static final String GRADLE_MIN_VERSION = '2.1'
static final String GRADLE_MIN_VERSION = '2.3'

static final String APPENGINE_SDK_CONFIGURATION_NAME = 'appengineSdk'
static final String APPENGINE_GROUP = 'Google App Engine'
Expand All @@ -75,6 +74,7 @@ class AppEnginePlugin implements Plugin<Project> {
static final String APPENGINE_ENHANCE = 'appengineEnhance'
static final String APPENGINE_UPDATE = 'appengineUpdate'
static final String APPENGINE_ROLLBACK = 'appengineRollback'
static final String APPENGINE_SET_DEFAULT_VERSION = 'appengineSetDefaultVersion'
static final String APPENGINE_UPDATE_INDEXES = 'appengineUpdateIndexes'
static final String APPENGINE_VACUUM_INDEXES = 'appengineVacuumIndexes'
static final String APPENGINE_UPDATE_TASK_QUEUES = 'appengineUpdateQueues'
Expand Down Expand Up @@ -141,6 +141,7 @@ class AppEnginePlugin implements Plugin<Project> {
configureWebAppDir(project)
configureAppConfig(project, appEnginePluginExtension)
configureExplodeWarTask(project, appEnginePluginExtension, explodedAppDirectory)
configureSetDefaultVersionTask(project, explodedAppDirectory)
configureStageAppTask(project, explodedAppDirectory, stagedAppDirectory)
configureRun(project, appEnginePluginExtension, explodedAppDirectory)
configureStop(project, appEnginePluginExtension)
Expand Down Expand Up @@ -378,6 +379,15 @@ class AppEnginePlugin implements Plugin<Project> {
appengineRollbackTask.group = APPENGINE_GROUP
}

private void configureSetDefaultVersionTask(Project project, File explodedAppDirectory) {
project.tasks.withType(SetDefaultVersionTask).whenTaskAdded { SetDefaultVersionTask appengineSetDefaultVersionTask ->
appengineSetDefaultVersionTask.conventionMapping.map(EXPLODED_WAR_DIR_CONVENTION_PARAM) { explodedAppDirectory }
}
SetDefaultVersionTask appengineSetDefaultVersionTask = project.tasks.create(APPENGINE_SET_DEFAULT_VERSION, SetDefaultVersionTask)
appengineSetDefaultVersionTask.description = 'Sets the given version as the default on App Engine.'
appengineSetDefaultVersionTask.group = APPENGINE_GROUP
}

private void configureUpdateIndexes(Project project) {
UpdateIndexesTask appengineUpdateIndexesTask = project.tasks.create(APPENGINE_UPDATE_INDEXES, UpdateIndexesTask)
appengineUpdateIndexesTask.description = 'Updates indexes on App Engine.'
Expand Down Expand Up @@ -722,18 +732,10 @@ class AppEnginePlugin implements Plugin<Project> {
}

private void addEclipseConfigurationForFunctionalTestRuntimeConfiguration(Project project, Configuration functionalTestRuntimeConfiguration) {
//TODO : once we up the minimum supported version, remove this conditional
if(VersionComparator.compare(project.gradle.gradleVersion, "2.3") < 0) {
project.plugins.withType(EclipsePlugin) { EclipsePlugin plugin ->
plugin.model.classpath.plusConfigurations += [functionalTestRuntimeConfiguration]
}
}
else {
project.afterEvaluate {
if (project.plugins.hasPlugin(EclipsePlugin)) {
EclipseModel model = project.extensions.getByType(EclipseModel)
model.classpath.plusConfigurations += [functionalTestRuntimeConfiguration]
}
project.afterEvaluate {
if (project.plugins.hasPlugin(EclipsePlugin)) {
EclipseModel model = project.extensions.getByType(EclipseModel)
model.classpath.plusConfigurations += [functionalTestRuntimeConfiguration]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.appengine.task.appcfg

import org.gradle.api.tasks.InputDirectory

/**
* Google App Engine task that sets the default version for a module
*
*/
class SetDefaultVersionTask extends AppConfigTaskTemplate {
static final String COMMAND = 'set_default_version'

@InputDirectory File explodedAppDirectory

@Override
String startLogMessage() {
'Starting setting default version...'
}

@Override
String errorLogMessage() {
'An error occurred setting default version.'
}

@Override
String finishLogMessage() {
'Finished setting default version.'
}

@Override
List getParams() {
[COMMAND, getExplodedAppDirectory().canonicalPath]
}
}
14 changes: 3 additions & 11 deletions src/test/groovy/com/google/appengine/ide/EclipseTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,8 @@ class EclipseTest {
project.apply plugin: "eclipse"
Configuration testConfig = project.configurations.getByName(AppEnginePlugin.FUNCTIONAL_TEST_RUNTIME_CONFIGURATION)

if (VersionComparator.compare(project.gradle.gradleVersion, "2.3") < 0) {
assert(project.plugins.hasPlugin(EclipsePlugin))
project.plugins.withType(EclipsePlugin) { EclipsePlugin plugin ->
assert(plugin.model.classpath.plusConfigurations.contains(testConfig))
}
}
else {
project.evaluate()
assert(project.plugins.hasPlugin(EclipsePlugin))
assert(project.extensions.getByType(EclipseModel).classpath.plusConfigurations.contains(testConfig))
}
project.evaluate()
assert(project.plugins.hasPlugin(EclipsePlugin))
assert(project.extensions.getByType(EclipseModel).classpath.plusConfigurations.contains(testConfig))
}
}

0 comments on commit 8543a34

Please sign in to comment.