groovy - Programically download dependencies in custom gradle task -
i'm new in groovy/gradle. want create task depends on few maven libraries. possible download libraries groovy code? want put code
configurations { sshexecanttask } repositories { mavencentral() } dependencies { sshexecanttask 'org.apache.ant:ant-jsch:1.7.0' } which use in way:
ant.taskdef(name: 'sshexec', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.sshexec', classpath: project.configurations.sshexecanttask.aspath) ant.sshexec(host: host, username: username, password: password, command: command, trust: 'true', failonerror: 'true') into defaulttask class. possible? should similar this:
class mycustomtask extends defaulttask { public mycustomtask() { super() // set , download dependencies here } } [edit]
i've found can in way:
project.getrepositories().mavenlocal() project.getconfigurations().create('sshexecanttask') project.getdependencies().add('sshexecanttask', 'org.apache.ant:ant-jsch:1.7.0') project.getconfigurations().getbyname('sshexecanttask').resolve() println('project.configurations.sshexecanttask.aspath: '+project.getconfigurations().getbyname('sshexecanttask').getaspath()); but still doesn't work. idea?
you typically along lines of:
mycustomtasklives in own build (possiblybuildsrc).- the
mycustomtaskproject declaresant-jschcompile dependency. - the task's action (not constructor) defines (
taskdef) , executes ant task. (might have wrappedproject.ant.execute { ... }.) - builds wish use
mycustomtaskdeclare build script dependency on module (not necessary in case ofbuildsrc). transitive dependency management automatically brings inant-jschalong it.
the customplugin sample in full gradle distribution place started. (just declare compile instead of testcompile dependency.)
Comments
Post a Comment