Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add dependency of type @jar in build.gradle using format of group,name,version,type?

The pom.xml of dependency is describle with <packaging>apk</packaging>,which isn't workable in compile. So I exclude the module in dependency tree and re-include by compile 'package:artifactId:versionName@jar' This does work,but what's the corresponding format of group:'groupName',name:'artifactId',version:'versionName',type:'type' ? I triedtype:'jar' which didn't work. And do I have to exclude the dependency in dependency tree first , then re-include it second ? Or I can modify the description of parent dependency ?

parent dependency:

compile (group:'parentGroupId',name:'parentModuleName',version:'parentVersion'){
    exclude group:'excludeGroupId',module:'excludeModuleName'
}

compile 'excludeGroupId:excludeModuleName:excludeVersion@jar'

I tried

compile (group:'parentGroupId',name:'parentModuleName',version:'parentVersion'){
    exclude group:'excludeGroupId',module:'excludeModuleName'
}

compile (group:'excludeGroupId',name:'excludeModuleName',version:'excludeVersion',type:'jar')

the above didn't work

like image 570
nyanpassu Avatar asked Oct 31 '22 18:10

nyanpassu


1 Answers

Based on the docs at http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html this looks like the correct way to specify this sort of dependency:

compile (group:'excludeGroupId',name:'excludeModuleName',version:'excludeVersion') {
    artifact {
        name = 'excludeModuleName'
        type = 'jar'
    }
}

Note that the redundant name spec inside artifact is required -- you'll get a NullPointerException without it.

like image 123
Scott Barta Avatar answered Nov 15 '22 03:11

Scott Barta