Gradle 1.3之前的Publishing artifacts


在Gradle1.3之前,Publishing artifacts是使用uploadConfigurationName来publish

声明artifacts是靠使用

build.gradle

artifacts {
    artifact
}

声明。

生成artifact:可以使用三种途径:

1、使用已定义的任务:

task myJar(type: Jar)
artifacts {
   archives myJar
}

2、使用一个file:

def someFile = file('build/somefile.txt')
artifacts {
  archives someFile
}

3、自定义一个artifact

task myTask(type: MyTaskType) {
  destFile = file('build/somefile.txt')
}
artifacts {
  archives(myTask.destFile) {
  name 'my-artifact'
  type 'text'
  builtBy myTask
  }
}

开始上传:

repositories {
 flatDir {
  name "fileRepo"
  dirs "repo"
  }
}
uploadArchives {
  repositories {
    add project.repositories.fileRepo
    ivy {
      credentials {
         username "username"
         password "pw"
       }
    url "http://repo.mycompany.com"
   }
  }
}

这个uploadArchives 其实就是uploadConfigurationName,其中archives就是上文中的artifacts 的configurationName

备注:gradle1.3之后采用新的机制上传组件,这个待下篇分讲。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM