Skip to content

Commit

Permalink
#1143: Add support for tomcat (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leosssss authored Jun 30, 2023
1 parent 015e8fa commit c3f73a1
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Release with new features and bugfixes:
* https://github.com/devonfw/ide/issues/1147[#1147]: Separates plugins from software folder
* https://github.com/devonfw/ide/issues/1158[#1158]: Projects main-branch is always checked out
* https://github.com/devonfw/ide/issues/1118[#1118]: Add milestone versions of Eclipse
* https://github.com/devonfw/ide/issues/1143: Add support for Tomcat

The full list of changes for this release can be found in https://github.com/devonfw/ide/milestone/44?closed=1[milestone 2023.05.001].

Expand Down
1 change: 1 addition & 0 deletions documentation/LICENSE.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ The following table shows the components that may be used. The column `inclusion
|https://cloud.google.com/sdk/gcloud[GCloudCLI]|Optional|https://github.com/twistedpair/google-cloud-sdk/blob/master/google-cloud-sdk/LICENSE[ASL 2.0]
|https://github.com/openrewrite/rewrite-maven-plugin[Openrewrite]|Optional|https://github.com/openrewrite/rewrite-maven-plugin/blob/main/LICENSE[ASL 2.0]
|https://kotlinlang.org//[kotlin]|Optional|https://github.com/JetBrains/kotlin-web-site/blob/master/LICENSE[ASL 2.0]
|https://tomcat.apache.org/[tomcat]|Optional|https://www.apache.org/licenses/LICENSE-2.0[ASL 2.0]
|=======================

== Apache Software License - Version 2.0
Expand Down
1 change: 1 addition & 0 deletions documentation/cli.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ The following commandlets are currently available:
* link:rewrite.asciidoc[rewrite]
* link:sonar.asciidoc[sonar]
* link:terraform.asciidoc[terraform]
* link:tomcat.asciidoc[tomcat]
* link:vscode.asciidoc[vscode]
* link:yarn.asciidoc[yarn]
2 changes: 2 additions & 0 deletions documentation/devonfw-ide-usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ include::kotlinc.asciidoc[leveloffset=3]

include::kotlinc-native.asciidoc[leveloffset=3]

include::tomcat.asciidoc[leveloffset=3]

include::kubectl.asciidoc[leveloffset=3]

include::lazydocker.asciidoc[leveloffset=3]
Expand Down
1 change: 1 addition & 0 deletions documentation/scripts.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ This directory is the heart of the `devonfw-ide` and contains the required link:
│ ├── link:rewrite.asciidoc[rewrite]
│ ├── link:sonar.asciidoc[sonar]
│ ├── link:terraform.asciidoc[terraform]
│ ├── link:tomcat.asciidoc[tomcat]
│ ├── link:vscode.asciidoc[vscode]
│ └── link:yarn.asciidoc[yarn]
├── link:cli.asciidoc[devon]
Expand Down
17 changes: 17 additions & 0 deletions documentation/tomcat.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:toc:
toc::[]

= Tomcat

The `Tomcat` commandlet allows to install install, configure, and launch https://tomcat.apache.org/[tomcat].

The arguments (`devon tomcat «args»`) are explained by the following table:

.Usage of `devon tomcat`
[options="header"]
|=======================
|*Argument(s)* |*Meaning*
|`setup` |setup Tomcat (install or update and verify), via `TOMCAT_VERSION` (use `devon tomcat version list` to get available versions or `devon tomcat version set [TAB]` to set version with auto-completion)
|`start` |start Tomcat
|`stop` |stop Tomcat
|=======================
82 changes: 82 additions & 0 deletions scripts/src/main/resources/scripts/command/tomcat
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env bash

# autocompletion list
if [ "${1}" = "shortlist" ]
then
if [ -z "${2}" ]
then
echo "setup start stop version help"
fi
exit
fi



# shellcheck source=scripts/functions
source "$(dirname "${0}")"/../functions
export CATALINA_HOME="${DEVON_IDE_HOME}/software/tomcat"
TOMCAT_HOME="${DEVON_IDE_HOME}/software/tomcat"
TOMCAT="${TOMCAT_HOME}/bin/catalina.sh"

TOOL_VERSION_COMMAND="${TOMCAT} version"
# shellcheck source=scripts/commandlet-cli
source "$(dirname "${0}")"/../commandlet-cli

# $1: optional silent mode
function doSetup() {
doDevonCommand java setup silent
doInstall "tomcat" "${TOMCAT_VERSION}" "${1}"
return 0
}

function doStart() {
# dosetup silent
# doRunCommand "${TOMCAT_HOME}/bin/startup.bat"#
doTomcat start
}

function doStop() {
doTomcat stop
}

function doTomcat() {
doSetup silent

if [ "${1}" = "start" ]
then
"${TOMCAT_HOME}/bin/startup.sh"
elif [ "${1}" = "stop" ]
then
"${TOMCAT_HOME}/bin/shutdown.sh"
else
doFail "Unknown tomcat command: ${1}"
fi

if [ "${1}" = "start" ]
then
echo "Tomcat is running at localhost on the following port (default 8080):"
grep 'Connector port=' "${TOMCAT_HOME}/conf/server.xml" | awk -F'"' '{print $2}'| head -1
fi
}

# CLI
if [ "${1}" = "-h" ] || [ "${1}" = "help" ]
then
echo "Setup or run Tomcat on local machine."
echo
echo "Arguments:"
echo " start start tomcat on your machine"
echo " stop stop tomcat on your machine"
echo " setup install tomcat on your machine (install, verify)"
elif [ "${1}" = "setup" ]
then
doSetup "${2}"
elif [ "${1}" = "start" ]
then
doStart
elif [ "${1}" = "stop" ]
then
doStop
else
doFail "undefined argument ${*}"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ protected boolean doAddVersion(UrlVersion urlVersion, String url, OperatingSyste

String version = urlVersion.getName();
url = url.replace("${version}", version);
String major = urlVersion.getVersionIdentifier().getStart().getDigits();
url = url.replace("${major}", major);
if (os != null) {
url = url.replace("${os}", os.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.devonfw.tools.ide.url.updater.quarkus.QuarkusUrlUpdater;
import com.devonfw.tools.ide.url.updater.sonar.SonarUrlUpdater;
import com.devonfw.tools.ide.url.updater.terraform.TerraformUrlUpdater;
import com.devonfw.tools.ide.url.updater.tomcat.TomcatUrlUpdater;
import com.devonfw.tools.ide.url.updater.vscode.VsCodeUrlUpdater;

/**
Expand All @@ -59,7 +60,7 @@ public class UpdateManager {
new IntellijCommunityUrlUpdater(), new JavaUrlUpdater(), new JenkinsUrlUpdater(), new KotlincUrlUpdater(),
new KotlincNativeUrlUpdater(), new LazyDockerUrlUpdater(), new MvnUrlUpdater(), new NodeUrlUpdater(),
new NpmUrlUpdater(), new OcUrlUpdater(), new PipUrlUpdater(), new PythonUrlUpdater(), new QuarkusUrlUpdater(),
new DockerRancherDesktopUrlUpdater(), new SonarUrlUpdater(), new TerraformUrlUpdater(), new VsCodeUrlUpdater());
new DockerRancherDesktopUrlUpdater(), new SonarUrlUpdater(), new TerraformUrlUpdater(), new TomcatUrlUpdater(), new VsCodeUrlUpdater());

/**
* The constructor.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.devonfw.tools.ide.url.updater.tomcat;

import java.util.regex.Pattern;

import com.devonfw.tools.ide.common.OperatingSystem;
import com.devonfw.tools.ide.url.model.folder.UrlVersion;
import com.devonfw.tools.ide.url.updater.GithubUrlUpdater;

/**
* {@link GithubUrlUpdater} for Tomcat.
*/
public class TomcatUrlUpdater extends GithubUrlUpdater {

@Override
protected String getTool() {

return "tomcat";
}

@Override
protected void addVersion(UrlVersion urlVersion) {
doAddVersion(urlVersion, "https://archive.apache.org/dist/tomcat/tomcat-${major}/v${version}/bin/apache-tomcat-${version}.zip");
}

@Override
protected String getGithubOrganization() {

return "apache";
}

@Override
protected String getGithubRepository() {

return "tomcat";
}
}

0 comments on commit c3f73a1

Please sign in to comment.