Converted Maven pom to Gradle script but dependencies are not shown


(Felix Gao) #1

I have a maven project that I converted to a gradle script using gradle init on the parent directory. The build.gradle looks correct.

allprojects  {
  apply plugin: 'maven'

  group = 'com.data.jabba'
  version = '20151215171929-SNAPSHOT'
}

subprojects {
  apply plugin: 'java'
  sourceCompatibility = 1.7
  targetCompatibility = 1.7

  task packageSources(type: Jar) {
  classifier = 'sources'
  from sourceSets.main.allSource
}

artifacts.archives packageSources
  repositories {
    mavenLocal()
    maven { url "http://repo.maven.apache.org/maven2" }
  }
  
  dependencies {
    compile group: 'com.google.inject', name: 'guice', version:'4.0'
    compile group: 'com.google.inject.extensions', name: 'guice-multibindings', version:'4.0'
    compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.3'
    testCompile group: 'junit', name: 'junit', version:'4.12'
    testCompile group: 'org.hamcrest', name: 'hamcrest-core', version:'1.3'
    testCompile group: 'org.hamcrest', name: 'hamcrest-library', version:'1.3'
    testCompile group: 'org.mockito', name: 'mockito-core', version:'1.10.19'
    testCompile group: 'org.powermock', name: 'powermock-core', version:'1.6.4'
    testCompile(group: 'org.powermock', name: 'powermock-api-mockito', version:'1.6.4') {
      exclude(module: 'mockito-all')
    }
    testCompile(group: 'org.powermock', name: 'powermock-module-junit4', version:'1.6.4') {
      exclude(module: 'junit')
    }
    testCompile group: 'org.easymock', name: 'easymock', version:'3.4'
    testCompile group: 'org.powermock', name: 'powermock-api-easymock', version:'1.6.4'
    testCompile group: 'org.assertj', name: 'assertj-core', version:'2.3.0'
    testCompile group: 'cglib', name: 'cglib', version:'3.2.0'
}
  
}

However, when I run gradle dependencies task it shows the following

Starting a new Gradle Daemon for this build (subsequent builds will be faster).
Parallel execution is an incubating feature.
:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

archives - Configuration for archive artifacts.
No dependencies

default - Configuration for default artifacts.
No dependencies

BUILD SUCCESSFUL

Total time: 4.187 secs

(Stefan Oehme) #2

You are calling the dependencies task on the root project. The root project has no dependencies in your case. Try calling gradle subProjectName:dependencies to get the dependencies of that sub project.