As the title says, I wanted to build an environment where I could execute steps with just the Maven command **.
I didn't have enough resources to launch Docker or VM, so I couldn't wait to clone & checkout and build, but I still wanted to do runtime variable check and version difference verification.
So, I thought that I should try using the ancient ** Codehaus Cargo (hereinafter Cargo) **, so this article was written. I will.
It's a tool that has been around for a long time, and the content is now renewed as "Is it Maven nowadays?"
--It is troublesome to keep the source at hand ** and build it ** -** The source on the application side cannot be tampered with ** (including pom.xml), change management is strict --I want to switch between different versions or start them at the same time ** -** Because there is no memory or room **, VMs and containers are a little ... --Even if you launch the IDE separately, you want to launch the app with one command. --The AP server is Jetty 9.4 series, which is light.
Prepare the following in advance.
It's sloppy, but it consists only of pom.xml and Jetty config file. Basically, the argument (-D option) at the time of executing the mvn command is used to do anything.
For the time being, the following command will run a sample application that just opens the data source ** org.codehaus.cargo: datasource-war **.
git clone https://github.com/Piecemeal-Technology-Inc/cargo-jetty-launcher.git
cd cargo-jetty-launcher
mvn initialize compile cargo:run
If you access http: // localhost: 8081 / change-context-root / test with your browser, you will see "Got connection!". The context root is controlled by context.path in pom.xml.
Launch VSCode and generate Java launch.json by "Run"-"Add Configuration". Therefore, add the following configuration to configurations.
launch.json
{
"type": "java",
"name": "Debug (Remote 9990)",
"request": "attach" , //Remote debug specification
"projectName" : "cargo-jetty-launcher",
"hostName": "localhost",
"port": 9990, // pom.xml debug.Match with port property
//Add a reference path to the source created under target
"sourcePaths": [
"${workspaceFolder}/target/sources-datasource-war.1.7.11/main",
"${workspaceFolder}/target/sources-datasource-war.1.7.11/dependency"
]
}
Now that the preparation is complete, you can execute steps by setting a breakpoint and starting the debugger.
※Caution ** This is a result of trial and error, so I don't think it's basically the theory street. ** ** If you use an embedded data source or don't include Jetty's own extension, it's okay if you do it normally as officially.
Since it is generalized to some extent with run-time arguments, it can be easily raised by preparing a command for each application you want to raise. In addition, since it does not have the substance such as source code, the execution environment can be expanded in PJ in a lightweight form.
I thought I'd write this story because I was really into Cargo, but I don't think there is any demand, so I'll omit it for the time being.
In the first place, the war and source-jar to be run must be in the local repository or remote repository. If you don't debug, you don't need source-jar, just war.
Recommended Posts