0

I am using the dependency section in my gradle script but I think I am crearting the duplication of the dependency in my script.I need the dependency during compilation time as well as during runtime.Do I need to define the dependency as a compile and runtime. Because for runtime my script is having a below logic

runtime.configuration and that way I am putting all the jar file to lib folder

Can I do both the things in one section?I mean I want only one dependency section compile or runtime.

Please suggest

dependencies {
        compile group: 'com.rohit.singh', name: 'common', version:'4.+'
        compile group: 'com.rohit.singh', name: 'LicenseVerifier', version:'4.+'
       compile group: 'com.rohit.singh', name: 'MegNativeJNI', version: '4.+', ext: 'so'
       compile group: 'com.rohit.singh', name: 'NativeJNI', version: '4.+', ext: 'so'
        compile(group: 'com.operasolutions', name: 'RiskAnalytics', version:'1.1') {
    exclude(module: 'jyson')
        }
        compile group: 'org.springframework', name: 'spring-context', version:'3.2.5.RELEASE'
        compile group: 'org.springframework', name: 'spring-beans', version:'3.2.5.RELEASE'
        compile group: 'org.springframework', name: 'spring-core', version:'3.2.5.RELEASE'
        compile group: 'org.springframework', name: 'spring-aop', version:'3.2.5.RELEASE'
        compile group: 'org.springframework', name: 'spring-expression', version:'3.2.5.RELEASE'
        compile group: 'org.apache.commons', name: 'commons-collections4', version:'4.0'
        compile group: 'commons-io', name: 'commons-io', version:'2.4'
        compile group: 'net.sf.supercsv', name: 'super-csv-dozer', version:'2.1.0'
        compile group: 'net.sf.supercsv', name: 'super-csv', version:'2.1.0'
        compile group: 'org.aspectj', name: 'aspectjtools', version:'1.6.2'
        compile group: 'org.python', name: 'jython-standalone', version:'2.5.3'
        compile group: 'com.google.code.gson', name: 'gson', version:'1.7.2'
        compile group: 'log4j', name: 'log4j', version:'1.2.16'
        compile group: 'com.xhaus', name: 'jyson', version:'1.0.2'
        compile group: 'com.google.guava', name: 'guava', version:'17.0'
        compile group: 'com.jamonapi', name: 'jamon', version:'2.4'
        compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.1'
        compile group: 'ch.qos.logback', name: 'logback-core', version:'1.1.1'
        compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.6'
        compile group: 'org.codehaus.mojo', name: 'properties-maven-plugin', version:'1.0-alpha-2'
        compile group: 'args4j', name: 'args4j', version:'2.0.28'
        compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version:'1.9.5'
        testCompile group: 'junit', name: 'junit', version:'4.11'
        testCompile group: 'org.mockito', name: 'mockito-all', version:'1.9.5'
    }
    dependencies {
        runtime group: 'com.rohit.singh', name: 'engine-common', version:'4.+'
        runtime group: 'com.rohit.singh', name: 'engine-LicenseVerifier', version:'4.+'
       runtime group: 'com.rohit.singh', name: 'MegNativeJNI', version: '4.+', ext: 'so'
      runtime group: 'com.rohit.singh', name: 'NativeJNI', version: '4.+', ext: 'so'
      runtime (group: 'com.operasolutions', name: 'RiskAnalytics', version:'1.1') {
      exclude(module: 'jyson')
        }
        runtime group: 'org.springframework', name: 'spring-context', version:'3.2.5.RELEASE'
        runtime group: 'org.springframework', name: 'spring-beans', version:'3.2.5.RELEASE'
        runtime group: 'org.springframework', name: 'spring-core', version:'3.2.5.RELEASE'
        runtime group: 'org.springframework', name: 'spring-aop', version:'3.2.5.RELEASE'
        runtime group: 'org.springframework', name: 'spring-expression', version:'3.2.5.RELEASE'
        runtime group: 'org.apache.commons', name: 'commons-collections4', version:'4.0'
        runtime group: 'commons-io', name: 'commons-io', version:'2.4'
        runtime group: 'net.sf.supercsv', name: 'super-csv-dozer', version:'2.1.0'
        runtime group: 'net.sf.supercsv', name: 'super-csv', version:'2.1.0'
        runtime group: 'org.aspectj', name: 'aspectjtools', version:'1.6.2'
        runtime group: 'org.python', name: 'jython-standalone', version:'2.5.3'
        runtime group: 'com.google.code.gson', name: 'gson', version:'1.7.2'
        runtime group: 'log4j', name: 'log4j', version:'1.2.16'
        runtime group: 'com.xhaus', name: 'jyson', version:'1.0.2'
        runtime group: 'com.google.guava', name: 'guava', version:'17.0'
        runtime group: 'com.jamonapi', name: 'jamon', version:'2.4'
        runtime group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.1'
        runtime group: 'ch.qos.logback', name: 'logback-core', version:'1.1.1'
        runtime group: 'org.slf4j', name: 'slf4j-api', version:'1.7.6'
        runtime group: 'org.codehaus.mojo', name: 'properties-maven-plugin', version:'1.0-alpha-2'
        runtime group: 'args4j', name: 'args4j', version:'2.0.28'
        runtime group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version:'1.9.5'
       }
unknown
  • 1,815
  • 3
  • 26
  • 51
  • http://gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html#configurations clearly states which dependencies are included in runtime scope. – Oleg Estekhin May 17 '15 at 04:59

1 Answers1

1

You already defined your dependencies in compile scope. There is no need to define them also for runtime. Compile scope dependencies will automatically be available at runtime.

You can also put compile dependencies to lib folder and exclude any dependency you don't need there. But i wonder if there is any dependency to exclude and if it is worth to build that logic for it.

I would suggest to make your build script as simple as possible.

Cengiz
  • 5,375
  • 6
  • 52
  • 77