How do you know what dependencies you need for your java file?

I am currently working on a build.xml file and I also have a Java file. But I am not sure what types of dependencies I would have to add to make the gradle file and java file work together.

gradle script

import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
import java.text.SimpleDateFormat
import java.util.Date

apply plugin: net.saliman.gradle.plugin.cobertura.CoberturaPlugin
apply plugin: 'java'
version = 1.0
apply plugin: 'war'

buildscript {
  repositories {
  jcenter()
  }
  dependencies {
    classpath 'net.saliman:gradle-cobertura-plugin:2.3.1'
  }
}

repositories {
mavenCentral()    
}
  configurations {
    junitAnt
//antJwsc
//jwsc
           }
          dependencies {

compile 'log4j:log4j:1.2.17'
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:slf4j-log4j12:1.7.5'
//antJwsc ''
//jwsc ''
//jwsc ''


junitAnt 'junit:junit:4.8.2'
junitAnt('org.apache.ant:ant-junit:1.9.2') {
    transitive = false
}
junitAnt('org.apache.ant:ant-junit4:1.9.2') {
    transitive = false
 }
}

/*
sourceSets {
main {
    java { srcDir 'src' }
    resources { srcDir 'src' }
    resources { srcDir 'WebContent/WEB-INF/lib' }
}


test {
    resources { srcDir 'test' }
}
}
*/

I converted a build.xml file to build.gradle file. But I don’t have the top part where it starts build script { repos, dependencies etc}. My question is how will I able to fill those in? Every time I add a dependency I receive an error for what ever I put under dependencies. Eg; could not find method testcompile{}.

Can you post your build.gradle file or an example that reproduces your problem?

So basically when I uncomment the source sets. I receive over 100 errors such as “package org.slf4j is not found”. I see all the errors are coming from my java file when I am importing. With sourceset commented out, my script runs fine.

So I am assuming that I am missing dependencies that will satisfy the java file.

Can the reason be; because I don’t have a maven repo structure which is why the source set is acting up?

This is the error sets I get wen I uncomment sourceSet in my gradle script. Would you need to see my java file also?