Gradle 6.5.1 gretty 3.0.3 unable to run jetty

1.5k Views Asked by At

I am trying to build my first REST API, using jersey on Eclipse. This is my build.gradle:

plugins {
    //id "com.dsvdsv.gradle.plugin" version "1.5.1"
    //id 'org.gretty' version '2.1.0'
    id "org.gretty" version "3.0.3"
    //id 'com.bmuschko.tomcat'
    id 'eclipse-wtp'
    id 'war'
    //id 'jetty'
    id 'org.springframework.boot' version '2.4.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id 'application'

}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
mainClassName = 'com.example.demo.DemoApplication'

repositories {
    mavenCentral()
    //jcenter()
}

dependencies {
    // https://mvnrepository.com/artifact/org.gretty/gretty-runner-tomcat85
    //compile group: 'org.gretty', name: 'gretty-runner-tomcat85', version: '2.2.0'

    implementation 'org.glassfish.jersey.containers:jersey-container-servlet:2.25.1'
    implementation 'org.glassfish.jersey.inject:jersey-hk2:2.26'
    implementation 'org.springframework.boot:spring-boot-starter'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    //implementation 'com.bmuschko:gradle-tomcat-plugin:2.5'
}

test {
    useJUnitPlatform()
}

When I use gradle jettyStart or gradle jettyRunWar, getting below error:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':jettyStart'.

Could not resolve all files for configuration ':grettyRunnerJetty94'. Could not find org.gretty:gretty-runner-jetty94:3.0.3. Required by: project :

I also tried gretty 2.1.0 version, but it's unreachable. Gradle version is 6.5.1

1

There are 1 best solutions below

0
On

As mentioned by @Knut Forkalsrud newer gretty versions are not in maven central and you need to add jcenter() to the list of repositories:

repositories {
    jcenter()
    mavenCentral()
    // other repositories
}

Additional Note: The order of repositories is also important (similar to maven). So make sure you add the jcenter() at the right place in your list of repositories.