How to solve package org.slf4j not found


#1

When I tried adding these below, into my dependencies I receive an error saying "could not find method compile<> for arguments [log4j:log etc…]

compile 'log4j:log4j:1.2.17’
compile 'org.slf4j:slf4j-api:1.7.5’
compile ‘org.slf4j:slf4j-log4j12:1.7.5’

script

        buildscript {
        repositories {
         jcenter()
        }
      dependencies {
      classpath 'net.saliman:gradle-cobertura-plugin:2.3.1'
       }
      }
      repositories {
       mavenCentral()
       }
     configurations {
     junitAnt
      }
      dependencies {
      compile 'log4j:log4j:1.2.17'
     compile 'org.slf4j:slf4j-api:1.7.5'
     compile 'org.slf4j:slf4j-log4j12:1.7.5'
     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
   }
  }
apply plugin: net.saliman.gradle.plugin.cobertura.CoberturaPlugin
apply plugin: 'java'
version = 1.0
apply plugin: 'war'

(Stefan Oehme) #2

You have to apply plugins before you can use them. Put the apply statements directly after the buildscript {} block and before everything else.


#3

I’ve done that I receive the same error


(Jaganmohan) #4

Try this, It worked
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
BUILD SUCCESSFUL

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
}
dependencies {
compile 'log4j:log4j:1.2.17’
compile 'org.slf4j:slf4j-api:1.7.5’
compile 'org.slf4j:slf4j-log4j12:1.7.5’
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
}
}