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之后采用新的机制上传组件,这个待下篇分讲。

原文地址:https://www.cnblogs.com/beiyeren/p/3836499.html