Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizing deployment directory of webapps #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ script:
fi
# test skin generation tool
- ./gradlew -u -i -S skinGenerate -DskinName=travis
# test deploy on customized webapps directory
- ./gradlew -u -i -S tomcatInstall -Dserver.webapps=.gradle/webapps
- ./gradlew -u -i -S tomcatStart -Dserver.webapps=.gradle/webapps
- ./gradlew -u -i -S tomcatStop -Dserver.webapps=.gradle/webapps
- ./gradlew -u -i -S tomcatClearLogs -Dserver.webapps=.gradle/webapps

cache:
directories:
Expand Down
6 changes: 6 additions & 0 deletions build.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
#
#server.base=

# (Optional) Webapps directory on which uPortal and portlets apps are deployed.
# This property permit to deploy all apps on a customized directory.
# Default value is on ${server.base}/webapps
#
#server.webapps=

# Location of Base Data Set; base data is imported before entities specified
# in implementation.entities.location (below) and does not commonly require
# adopter customization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class GradleTomcatDeployPlugin implements Plugin<Project> {
mustRunAfter project.rootProject.tasks.tomcatInstall

doFirst {
File serverBase = project.rootProject.file(project.rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = project.rootProject.file(project.rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")
logger.lifecycle("Removing deployed application from servlet container at location: ${deployDir}")
delete deployDir
}
Expand All @@ -27,8 +27,8 @@ class GradleTomcatDeployPlugin implements Plugin<Project> {
dependsOn 'assemble'

doFirst {
File serverBase = project.rootProject.file(project.rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = project.rootProject.file(project.rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")
logger.lifecycle("Deploying assembled application to servlet container at location: ${deployDir}")

String artifactDir = project.plugins.hasPlugin(GradlePlutoPlugin) ? 'pluto' : 'libs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import org.gradle.api.Project
class PortalShellInvoker {

void invoke(Project project, String scriptLocation, String... args) {
File serverBase = project.rootProject.file(project.rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = project.rootProject.file(project.rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")

project.ant.setLifecycleLogLevel('INFO')
project.ant.java(fork: true, failonerror: true, dir: project.rootProject.projectDir, classname: 'org.apereo.portal.shell.PortalShell') {
Expand Down
6 changes: 6 additions & 0 deletions buildSrc/src/main/resources/buildDefaults.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ server.home=.gradle/tomcat
#
#server.base=.gradle/tomcat

# (Optional) Webapps directory on which uPortal and portlets apps are deployed.
# This property permit to deploy all apps on a customized directory.
# Default value is on ${server.base}/webapps
#
#server.webapps=

# Location of Base Data Set; base data is imported before entities specified
# in implementation.entities.location (below) and does not commonly require
# adopter customization.
Expand Down
4 changes: 2 additions & 2 deletions gradle/tasks/portlet.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ task deployPortletApp() {
destinationDir.mkdir()
File archiveOutput = new File(destinationDir, warfile.getName())

File serverBase = file(project.rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File(serverBase, "webapps/${FilenameUtils.removeExtension(warfile.getName())}")
File serverWebapps = file(project.rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File(serverWebapps, "${FilenameUtils.removeExtension(warfile.getName())}")
logger.lifecycle("Deploying portlet application ${warfile} to location ${deployDir}")

AssemblerConfig config = new AssemblerConfig()
Expand Down
11 changes: 9 additions & 2 deletions gradle/tasks/properties.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import java.nio.file.Paths

/*
* Allows a collection of Java versions to be supported.
* If the currect Java version is unsupported, it will stop the current task execution.
Expand Down Expand Up @@ -115,6 +113,15 @@ task portalProperties() {
buildProperties.setProperty('portal.home', portalHome)
}

/*
* Step Seven: Calculate server.webapps (if absent)
*/
if (!buildProperties.containsKey('server.webapps')) {
// Still need to check for a JVM argument...
String serverWebapps = System.getProperty('server.webapps') ?: "${buildProperties.getProperty('server.base')}/webapps"
buildProperties.setProperty('server.webapps', serverWebapps)
}

/*
* List the complete set of build properties to the console.
*/
Expand Down
54 changes: 42 additions & 12 deletions gradle/tasks/tomcat.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,27 @@ task tomcatZip {

doLast {
String serverBase = rootProject.ext.buildProperties.getProperty('server.base')
ant.zip(destfile: 'tomcat-uportal.zip') {
zipfileset (
dir: "${serverBase}",
prefix: 'tomcat',
excludes: 'logs/**/*, temp/**/*, work/**/*'
)
String serverWebapps = rootProject.ext.buildProperties.getProperty('server.webapps')
if (serverWebapps.startsWith(serverBase)) {
ant.zip(destfile: 'tomcat-uportal.zip') {
zipfileset (
dir: "${serverBase}",
prefix: 'tomcat',
excludes: 'logs/**/*, temp/**/*, work/**/*'
)
}
} else {
ant.zip(destfile: 'tomcat-uportal.zip') {
zipfileset(
dir: "${serverBase}",
prefix: 'tomcat',
excludes: 'logs/**/*, temp/**/*, work/**/*'
)
zipfileset(
dir: "${serverWebapps}",
prefix: 'webapps'
)
}
}
}
}
Expand All @@ -209,12 +224,27 @@ task tomcatTar {

doLast {
String serverBase = rootProject.ext.buildProperties.getProperty('server.base')
ant.tar(destfile: 'tomcat-uportal.tgz', compression: 'gzip', longfile: 'gnu') {
tarfileset (
dir: "${serverBase}",
prefix: 'tomcat',
excludes: 'logs/**/*, temp/**/*, work/**/*'
)
String serverWebapps = rootProject.ext.buildProperties.getProperty('server.webapps')
if (serverWebapps.startsWith(serverBase)) {
ant.tar(destfile: 'tomcat-uportal.tgz', compression: 'gzip', longfile: 'gnu') {
tarfileset (
dir: "${serverBase}",
prefix: 'tomcat',
excludes: 'logs/**/*, temp/**/*, work/**/*'
)
}
} else {
ant.tar(destfile: 'tomcat-uportal.tgz', compression: 'gzip', longfile: 'gnu') {
tarfileset (
dir: "${serverBase}",
prefix: 'tomcat',
excludes: 'logs/**/*, temp/**/*, work/**/*'
)
tarfileset (
dir: "${serverWebapps}",
prefix: 'webapps'
)
}
}
}
}
8 changes: 4 additions & 4 deletions overlays/Announcements/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ dataInit {
* Drop (if present) then create the Hibernate-managed schema.
*/
doLast {
File serverBase = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")

ant.setLifecycleLogLevel('INFO')
ant.java(fork: true, failonerror: true, dir: rootProject.projectDir, classname: 'org.jasig.portlet.announcements.SchemaCreator') {
Expand All @@ -69,8 +69,8 @@ dataInit {
* specified by 'implementation.entities.location'.
*/
doLast {
File serverBase = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")
String implementationEntitiesLocation = PortalShellInvoker.createGroovySafePath(rootProject.ext['buildProperties'].getProperty('implementation.entities.location'))

ant.setLifecycleLogLevel('INFO')
Expand Down
8 changes: 4 additions & 4 deletions overlays/CalendarPortlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ dataInit {
* Drop (if present) then create the Hibernate-managed schema.
*/
doLast {
File serverBase = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")

/*
* The following specifies failonerror=false because it will produce an exception like...
Expand Down Expand Up @@ -81,8 +81,8 @@ dataInit {
* specified by 'implementation.entities.location'.
*/
doLast {
File serverBase = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")
String implementationEntitiesLocation = PortalShellInvoker.createGroovySafePath(rootProject.ext['buildProperties'].getProperty('implementation.entities.location'))

ant.setLifecycleLogLevel('INFO')
Expand Down
8 changes: 4 additions & 4 deletions overlays/NewsReaderPortlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ dataInit {
* Drop (if present) then create the Hibernate-managed schema.
*/
doLast {
File serverBase = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")

/*
* The following specifies failonerror=false because it will produce an exception like...
Expand Down Expand Up @@ -80,8 +80,8 @@ dataInit {
* specified by 'implementation.entities.location'.
*/
doLast {
File serverBase = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")
String implementationEntitiesLocation = PortalShellInvoker.createGroovySafePath(rootProject.ext['buildProperties'].getProperty('implementation.entities.location'))

ant.setLifecycleLogLevel('INFO')
Expand Down
7 changes: 2 additions & 5 deletions overlays/SimpleContentPortlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ war {
/*
* Import/Export Support
*/

import org.apereo.portal.start.shell.PortalShellInvoker

dependencies {
impexp configurations.jdbc
impexp "${portletApiDependency}"
Expand All @@ -47,8 +44,8 @@ dataInit {
* Drop (if present) then create the Hibernate-managed schema.
*/
doLast {
File serverBase = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.base'))
File deployDir = new File (serverBase, "webapps/${project.name}")
File serverWebapps = rootProject.file(rootProject.ext['buildProperties'].getProperty('server.webapps'))
File deployDir = new File (serverWebapps, "${project.name}")

ant.setLifecycleLogLevel('INFO')
ant.java(fork: true, failonerror: true, dir: rootProject.projectDir, classname: 'org.jasig.portlet.attachment.util.SchemaCreator') {
Expand Down