How to select specific jetty version in Gretty plugin - gradle

I am using Gretty plugin for running web application from Gradle script. Is it possible to select a specific version of jetty container to run? Not just jetty9 vs jetty8, but e.g. 9.2.13.v20150730

Since Gretty 2.0.0 it is possible to override versions of Jetty and servlet-api using gradle.properties file: http://akhikhl.github.io/gretty-doc/Overriding-servlet-container-versions.html
For instance:
jetty9Version = 9.2.22.v20170606

Related

What version of java does gradle use to run your application?

I have a JavaFX project I am working on using Gradle. What version of java is used when I use the gradle run task from the application plugin?
In IntelliJ I can go into the Gradle settings and change the "Gradle JVM" to any version I want. Is this just the version of java that is used to run the build? Or is this also the version that my application will be run on?
Where does my JAVA_HOME come into this, if at all?
Irrespective of IDEs, Gradle will use whatever language level of the JVM that is running Gradle. Typically whatever the value is for JAVA_HOME.
See Environment variables and Targeting a specific Java version
The new way to do it as of Gradle 6.7 is to use Toolchains for JVM projects
Your IDE should respect whatever Gradle configuration that is configured.

Alternatives to the Gradle Gretty Plugin

I’m trying to upgrade some old code that used the Jetty plugin in Gradle. I would like to upgrade the Gradle version beyond Gradle v3.5, but Gradle v4.0 and above has the Jetty plugin removed. Unfortunately, we are now required to use Gretty.
I’m using IntelliJ. My problems with the newer Gretty plugin are:
JVM Args and System properties specified on the commandline have to be manually put into the Gretty configuration.
At least in IntelliJ, I could do out of the box debugging with the Jetty plugin, but need to run two executions including the app and the Remote, and use a different Gradle task for debugging (e.g. jettyRunDebug) with Gretty.
What are the alternatives to Gretty? Anything that can substitute for the old Jetty plugin.
How about just skipping the Gretty plugin entirely and just using Unit testing?
See: https://stackoverflow.com/a/29759263/775715

Which version gradle will download if I do not specify any version in spring boot application?

I am working on spring boot application and did not specify any version in my build.gradle file,please see the below code.
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.postgresql:postgresql')
}
How gradle will automatically decide the version ?
If we talking about Gradle version. There are two options:
if in the project you have Gradle wrapper that you can specify the version in gradle.properties file in the gradle/wrapper directory and run specific Gradle version using the command ./gradlew build wrapper details
in case if you don't have wrapper then you need specify some version in Path of your local machine. It can be checked via command gradle --version instalation details
If we talking about dependencies we also have two options:
Gradle will download the latest version of the artifact from added repository repository details
Use bom to specify set of artifacts versions bom details

Upgrade Jetty version to 9.4.8 in build.gradle

I am currently using the following gretty configuration in build.gradle:
gretty {
servletContainer = 'jetty9'
}
I want to upgrade the jetty version to 9.4.8.
From a quick search I found that jetty9 stands for the version Jetty 9.2.22.v20170606 (from: http://akhikhl.github.io/gretty-doc/Switching-between-servlet-containers.html). I couldn't anything on how to upgrade to jetty version 9.4.8. Could someone please help.
Yeah, from this doc, you can configure gretty to use 'jetty9.4' (jdk 8 only) instead of jetty9.
In the latest v2.0.0 release, plugin will work with jetty9 of 9.2.22.v20170606 and jetty9.4 of v9.4.6.v20170531, respectively.(ref)
jetty9_version=9.2.22.v20170606
jetty94_version=9.4.6.v20170531
You can PR for jetty94_version.
[updated]
I have created a sample project using Spring MVC with Jetty 9.4.8 particularly in this commit.
[edit note]
Please use 'jetty9.4' (instead of 'jetty94') - Refer to this github comment for more info

Spark microframework 2.1 deploys well in Tomcat but not version 2.5

I am not good at all this web stuff, but I have managed to port a small Spark-tinyweb application to serve REST services from jetty to Tomcat, following the project from Leonan Luppi in
https://github.com/leonanluppi/SparkTomcat
But in the folder WebContent/WEB-INF/lib, if I replace the file
spark-core-2.1.jar
to a newer version:
spark-core-2.5.jar
The application does not work.
Any suggestions?
Your build.gradle file specifies the dependency on com.sparkjava:spark-core:2.1. You have to upgrade the version in the file too so that Gradle can resolve the dependencies and compile your app.

Resources