Packages don't exist

Hello everybody, I just began to use Gradle and started with a very simple eclipse project. I need to use a couple of libraries, but when I run gradle build I gor the following errors:

error: package org.springframework.aop does not exist
error: package org.apache.log4j does not exist

here is my build.gradle file:

apply plugin: "java"
apply plugin: "maven"
apply plugin: 'eclipse'
  group = "myorg"
version = 1.0
  repositories {
  sourceSets.all { set ->
    def jarTask = task("${}Jar", type: Jar) {
        baseName = baseName + "-$"
        from set.output
      artifacts {
        archives jarTask
  sourceSets {
  dependencies {
    apiCompile 'commons-codec:commons-codec:1.5'
      implCompile sourceSets.api.output
    implCompile 'commons-lang:commons-lang:2.6'
      testCompile 'junit:junit:4.9'
    testCompile sourceSets.api.output
    testCompile sourceSets.impl.output
    runtime configurations.apiRuntime
    runtime configurations.implRuntime
  jar {
    from sourceSets.api.output
    from sourceSets.impl.output
  uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: uri("${buildDir}/repo"))
              addFilter("main") { artifact, file -> == }
            ["api", "impl"].each { type ->
                addFilter(type) { artifact, file ->"-$type") }
                                  // We now have to map our configurations to the correct maven scope for each pom
                ["compile", "runtime"].each { scope ->
                    configuration = configurations[type + scope.capitalize()]
                    ["main", type].each { pomName ->
                        pom(pomName).scopeMappings.addMapping 1, configuration, scope

then in a java class I use:

import org.springframework.aop.*;
import org.apache.log4j.*

which generate the error. Please note that building in eclipse works fine. Any suggestion?

Looks like ‘compile’ isn’t being added to ‘apiCompile’ and ‘implCompile’, but needs to be.

Hello Peter, thank you for your answer, but i didn’t get it… can you give me more details about your idea? I tried

apicompile 'log4j:log4j:1.2.17'

but this gives me

Could not find method apicompile() for arguments [log4j:log4j:1.2.17] on root project 'AccMan'

ooops… sorry, it is case sensitive. This configuration solved the problem:

apiCompile 'log4j:log4j:1.2.17'
apiCompile 'org.springframework:spring-aop:4.1.1.RELEASE'