0

I have a Gradle, Intellij-idea project and I'm using ratpack. I'm trying to use the ratpack.test library to test my API however it cannot seem to find the ratpack.test package.

When compiling it says package ratpack.test does not exist.

Gradle: io.ratpack:ratpack-test 1.7.5 is in my external libraries and module.

Upon the error if I hover over the ratpack.test import it says add library 'Gradle: io.ratpack:ratpack-test 1.7.5' to classpath which I click. Then when I try to build again it breaks with the same error.

build.gradle file

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.ratpack:ratpack-gradle:1.7.5"
    }
}

plugins {
    id 'java'
}

group 'MIR.Interviwer.API'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    jcenter()
}

apply plugin: "io.ratpack.ratpack-java"
apply plugin: "idea"

dependencies {
    testCompile 'junit:junit:4.12'
    compile 'junit:junit:4.12'
    runtime "org.slf4j:slf4j-simple:1.7.25"
    runtime "com.h2database:h2:1.4.199"
}

ratpack.baseDir = file('ratpack')

Any ideas? Thanks.

A Redfearn
  • 506
  • 5
  • 15

1 Answers1

2

The only thing I can think of is if you are attempting to import the Ratpack test classes in your main module, where they are not available (after all, they are test classes and are only available in the test module).

Just as a heads up, you are also using deprecated configurations. So unless you are in a legacy project with an old version, use these instead:

  • testCompile -> testImplementation
  • compile -> implementation
  • runtime -> runtimeOnly

You can also get rid of the entire buildscript block and the apply plugin: "io.ratpack.ratpack-java" line, and just type:

plugins {
  id "io.ratpack.ratpack-java" version "1.7.5"
}
Bjørn Vester
  • 6,851
  • 1
  • 20
  • 20
  • Thanks tided up the build file! Do you know how I'd go about fixing the problem you stated in your opening paragraph? First time using Java/Gradle! – A Redfearn Oct 15 '19 at 16:50
  • 1
    Are the classes into which you're trying to import `ratpack.test` in `src/main/java` or `src/test/java`, @ARedfearn? – Kris Oct 15 '19 at 18:41
  • @kris they're in src/main/java – A Redfearn Oct 15 '19 at 19:49
  • 1
    Yep you're right just tried to build in src/test/java and it works... naive mistake by me. Thanks for the help! – A Redfearn Oct 15 '19 at 20:02