Skip to content

Commit

Permalink
Customizing deployment directory of webapps
Browse files Browse the repository at this point in the history
  • Loading branch information
jgribonvald committed May 21, 2018
1 parent b577026 commit 92ed608
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 39 deletions.
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 @@ -46,8 +46,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 @@ -67,8 +67,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 @@ -46,8 +46,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 @@ -79,8 +79,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 @@ -46,8 +46,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 @@ -79,8 +79,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 @@ -32,9 +32,6 @@ war {
/*
* Import/Export Support
*/

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

dependencies {
impexp configurations.jdbc
impexp "${portletApiDependency}"
Expand All @@ -46,8 +43,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

0 comments on commit 92ed608

Please sign in to comment.