Advertisement
Guest User

UploadNexus.gradle

a guest
Apr 6th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 2.25 KB | None | 0 0
  1. def userHome = new File(System.properties.'user.home' as String)
  2.  
  3. def localReleaseRepoFile = new File(userHome, 'local-gradle-repository/release')
  4. def localSnapshotRepoFile = new File(userHome, 'local-gradle-repository/snapshot')
  5. def localReleaseRepo = localReleaseRepoFile.toURI().toURL().toString()
  6. def localSnapshotRepo = localSnapshotRepoFile.toURI().toURL().toString()
  7.  
  8. ext {
  9.     localReleaseRepoFile = new File(userHome, 'local-gradle-repository/release')
  10.     localSnapshotRepoFile = new File(userHome, 'local-gradle-repository/snapshot')
  11.     localReleaseRepo = localReleaseRepoFile.toURI().toURL().toString()
  12.     localSnapshotRepo = localSnapshotRepoFile.toURI().toURL().toString()
  13. }
  14.  
  15. initscript {
  16.     repositories {
  17.         mavenLocal()
  18.         jcenter()
  19.         mavenCentral()
  20.     }
  21.     dependencies {
  22.         // needed for syncSnapshot and syncStaging
  23.         classpath 'org.apache.maven.wagon:wagon-webdav-jackrabbit:2.10'
  24.         classpath 'commons-codec:commons-codec:1.10'
  25.     }
  26. }
  27.  
  28. rootProject {
  29.     task(group: 'Repository', description: 'Sync local staging-repository to oss.sonatype.org.', 'syncCompanyStaging') << {
  30.         def stagingRepos = new org.apache.maven.wagon.repository.Repository('staging', 'http://xxx/nexus/content/repositories/releases')
  31.         def auth = new org.apache.maven.wagon.authentication.AuthenticationInfo()
  32.         auth.userName = nexusUserName
  33.         auth.password = nexusPassword
  34.         def wagon = new org.apache.maven.wagon.providers.webdav.WebDavWagon()
  35.  
  36.         wagon.connect(stagingRepos, auth)
  37.         localReleaseRepoFile.eachFile {
  38.             if (it.directory) {
  39.                 wagon.putDirectory(it, it.name)
  40.             } else {
  41.                 wagon.put(it, it.name)
  42.             }
  43.         }
  44.     }
  45.     task(group: 'Repository', description: 'Sync local SNAPSHOT-repository to oss.sonatype.org.', 'syncCompanySnapshot') << {
  46.         def snapshotRepos = new org.apache.maven.wagon.repository.Repository('snapshot', 'http://xxx/nexus/content/repositories/snapshots')
  47.         def auth = new org.apache.maven.wagon.authentication.AuthenticationInfo()
  48.         auth.userName = nexusUserName
  49.         auth.password = nexusPassword
  50.         def wagon = new org.apache.maven.wagon.providers.webdav.WebDavWagon()
  51.  
  52.         wagon.connect(snapshotRepos, auth)
  53.         localSnapshotRepoFile.eachFile {
  54.             if (it.directory) {
  55.                 wagon.putDirectory(it, it.name)
  56.             } else {
  57.                 wagon.put(it, it.name)
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement