Skip to content

Commit

Permalink
[WIP] intial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jgribonvald committed Oct 17, 2024
1 parent dcc9acc commit ed19582
Show file tree
Hide file tree
Showing 28 changed files with 1,555 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# These are explicitly windows files and should use crlf
*.bat text eol=crlf

31 changes: 31 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Prepare project
run: cp build.properties.sample build.properties
- name: Run tasks
run: ./gradlew tomcatInstall && ./gradlew tomcatDeploy
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ gradle-app.setting
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

.settings/*
**/.settings/**

# ignore local deployement properties
build.properties
4 changes: 4 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=21.0.4-tem
#java=11.0.22-tem
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# cas-deployer
Desployer for CAS since version 7.1
Deployer for CAS since version 7.1

gradle-war-deployer for cas
embed deployed app on tomcat, like the tomcat-manager, psi-probe
66 changes: 66 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import org.gradle.internal.os.OperatingSystem
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds
*/

plugins {
// Records all tasks in task graph, generates `build/reports/visteg.dot`
// dot file can be converted to an image using graphviz. `dot -Tsvg -O -v visteg.dot`
// id 'cz.malohlava' version '1.0.3'

//id 'net.foragerr.jmeter' version '1.1.0-4.0'
}

apply plugin: "eclipse"
apply plugin: "idea"

ext {
/*
* We need to define the buildProperties extended property here in order for the
* build to compile. It will be bootstrapped during the Gradle initialization phase.
*/
buildProperties = new Properties()

/*
* Unfortunately, several of the uPortal CLI tasks need to do
* significantly different things on different operating systems.
*/
isWindows = OperatingSystem.current().isWindows()
}


eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
}
}

idea {
module {
downloadJavadoc = true
downloadSources = true
}
}

apply from: rootProject.file('gradle/tasks/properties.gradle')
apply from: rootProject.file('gradle/tasks/tomcat.gradle')

/*
* If gradle/tasks/custom.gradle exists, tasks from that
* file will be made available
*/
File customTasks = rootProject.file('gradle/tasks/custom.gradle')

if(customTasks.isFile()) {
apply from: customTasks
}


apply plugin: 'java'
compileJava {
dependsOn javaVersionCheck
}
38 changes: 38 additions & 0 deletions build.properties.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Modify this file to suit your local environment.
# The values of these properties will
# override the values of properties of the
# same name in the buildDefaults.properties file.
#
# Use forward slashes for path names even if
# you are in a Windows environment!
#
# IMPORTANT! If you modify the value of either server.home or server.base, it is likely you will
# want to modify the other value as well. The default value of server.base is NOT calculated from
# server.home.

# Location of the integrated Tomcat installation; e.g. server.home=${env.CATALINA_HOME}. This
# property corresponds with the ${catalina.home} property within Tomcat (see Tomcat/bin/catalina.sh).
#
server.home=/opt/${user}/tomcat

# (Optional) Base directory for resolving dynamic portions of the integrated Tomcat installation.
# This property corresponds with the ${catalina.base} property within Tomcat (see
# Tomcat/bin/catalina.sh).
#
#server.base=/opt/tomcat_run

# (Optional) Webapps directory on which uPortal and portlets apps are deployed.
# This property permti to deploy apps on a customized directory. Default value will
# be on ${server.base}/webapps
#
server.webapps=/opt/${user}/webapps

# (Optional) project home directory where all karuta's project will found there config directories
# This property permit to set where to deploy at tomcatInstall the default configuration files
# This is the default path configuration
#
# project.home=${server.base}

# Location of static cached files
server.sharedCacheDir=/opt/${user}/cache
19 changes: 19 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* The buildSrc is a separate Gradle project and does not source
* gradle.properties; but we can make that happen, since we have
* some properties in common.
*/
String gradlePropsLocation = new File('gradle.properties').exists() ? 'gradle.properties' : '../gradle.properties'
Properties gradleProperties = new Properties()
gradleProperties.load(new FileInputStream(gradlePropsLocation))
ext {
gradleProperties.each { name, value ->
set(name, value)
}

}

repositories {
mavenLocal()
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.esco.script.gradle.plugins

import org.gradle.api.Plugin
import org.gradle.api.Project

class GradleCustomTasksPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.task('initDirCache') {
group 'custom'
description 'Create the shared cache directory'
dependsOn project.rootProject.tasks.projectProperties

doFirst {
logger.lifecycle("Check if shared cache directory already exist, else will create it !");
String cacheDir = project.rootProject.ext['buildProperties'].getProperty('server.sharedCacheDir')
logger.lifecycle("Shared Cache Directory properties defined on path '${cacheDir}'");
File dir = new File((String)cacheDir);
if (!dir.exists()) {
logger.lifecycle("Shared cache directory not already existing, will create it '${cacheDir}'");
dir.mkdir();
}
}
}
project.tasks.tomcatDeploy.dependsOn 'initDirCache'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.esco.script.gradle.plugins

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.Delete

class GradleTomcatDeployPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.task('tomcatClean', type: Delete) {
group 'Tomcat'
description 'Removes this project from the integrated Tomcat servlet container'
dependsOn project.rootProject.tasks.projectProperties
mustRunAfter project.rootProject.tasks.tomcatInstall

doFirst {
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
}
}
project.task('tomcatDeploy') {
group 'Tomcat'
description 'Deploys this project to the integrated Tomcat servlet container'
dependsOn 'tomcatClean'
dependsOn 'assemble'

doFirst {
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}")

File warFile = new File("${project.buildDir}/libs/${project.war.archiveName}")

project.copy {
with project.copySpec {
from project.zipTree(warFile)
}
into deployDir
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package scaldingspoon.gradle

import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.plugins.WarPlugin
import org.gradle.api.tasks.bundling.War

/**
* Plugin class to support WAR overlay
*/
class WarOverlayPlugin implements Plugin<Project> {
@Override
void apply(Project project) {
project.plugins.apply(WarPlugin)
project.convention.plugins.warOverlay = new WarOverlayPluginConvention()

project.tasks.withType(War, new Action<War>() {
@Override
void execute(War war) {
war.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
war.doFirst {
war.classpath = war.classpath.filter { !it.name.endsWith(".war") }

war.project.configurations.runtime.each {
if (it.name.endsWith(".war")) {
def fileList = war.project.zipTree(it)
if (project.convention.plugins.warOverlay.includeWarJars) {
war.from fileList
} else {
war.from fileList.matching { exclude "**/*.jar" }
}
}
}
}
}
})
}
}

/**
* Plugin convention to configure war overlay specific parameters
*/
class WarOverlayPluginConvention {
boolean includeWarJars = false

def warOverlay(Closure c) {
c.delegate = this
c()
}

def methodMissing(String name, args) {
this."${name}" = args[0]
}
}
26 changes: 26 additions & 0 deletions buildSrc/src/main/resources/buildDefaults.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Adopting institutions should modify this file to include adopter-specific
# defaults. These settings will apply to the build only if they are not
# overridden by higher-priority means. You can override these settings by
# providing a build.properties file or with JVM arguments.
#
# Use forward slashes for path names even if
# you are in a Windows environment!
#

# Location of the integrated Tomcat installation; e.g. server.home=${env.CATALINA_HOME}. This
# property corresponds with the ${catalina.home} property within Tomcat (see Tomcat/bin/catalina.sh).
#
server.home=.gradle/tomcat

# (Optional) Base directory for resolving dynamic portions of the integrated Tomcat installation.
# This property corresponds with the ${catalina.base} property within Tomcat (see
# Tomcat/bin/catalina.sh).
#
#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=
36 changes: 36 additions & 0 deletions etc/tomcat/bin/setenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Display settings at startup
CATALINA_OPTS="$CATALINA_OPTS -XX:+PrintCommandLineFlags"

# Prevent "Unrecognized Name" SSL warning
CATALINA_OPTS="$CATALINA_OPTS -Djsse.enableSNIExtension=true"

# We need to send a 'project.home' system property to the JVM; use the value of PROJECT_HOME, if
# present, or fall back to a value calculated from $CATALINA_BASE

# [ -z "$PROJECT_HOME" ] && PROJECT_HOME="$CATALINA_BASE/PROJECT"
# echo "PROJECT_HOME=$PROJECT_HOME"
# CATALINA_OPTS="$CATALINA_OPTS -Dproject.home=$PROJECT_HOME"

# Checking if anyother garbage collectors have been defined. If no other garbage
# collector is present, default to G1GC
# List of options taken from:
# http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html
echo $CATALINA_OPTS | grep -e '-XX:+UseSerialGC' -e '-XX:+UseParallelGC' -e '-XX:ParallelGCThreads' -e '-XX:+UseParallelOldGC' -e '-XX:+UseConcMarkSweepGC' -e '-XX:+UseParNewGC' -e '-XX:+CMSParallelRemarkEnabled' -e '-XX:CMSInitiatingOccupancyFraction' -e '-XX:+UseCMSInitiatingOccupancyOnly' -e '-XX:+UseG1GC'
if [ $? -eq 1 ]
then
CATALINA_OPTS="$CATALINA_OPTS -XX:+UseG1GC"
fi

# Check to see if heap space allocation has been set
# If there are already set values, leave them be
echo $CATALINA_OPTS | grep -e '-Xms'
if [ $? -eq 1 ]
then
CATALINA_OPTS="$CATALINA_OPTS -Xms1G"
fi

echo $CATALINA_OPTS | grep -e '-Xmx'
if [ $? -eq 1 ]
then
CATALINA_OPTS="$CATALINA_OPTS -Xmx4G"
fi
Loading

0 comments on commit ed19582

Please sign in to comment.