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:

  • mycustomtask lives in own build (possibly buildsrc).
  • the mycustomtask project declares ant-jsch compile dependency.
  • the task's action (not constructor) defines (taskdef) , executes ant task. (might have wrapped project.ant.execute { ... }.)
  • builds wish use mycustomtask declare build script dependency on module (not necessary in case of buildsrc). transitive dependency management automatically brings in ant-jsch along it.

the customplugin sample in full gradle distribution place started. (just declare compile instead of testcompile dependency.)


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -