How to upload artifact to network drive using gradle?

折月煮酒 提交于 2019-12-11 00:48:52

问题


I am reading this:

http://www.gradle.org/docs/current/userguide/artifact_management.html

to understand how to publish/upload my artifact to a network drive/fileshare which is a requirement (we have a maven repo up and running but some artifacts needs to be dumped on a fileshare). The examples I have found are more focused on deploying to repositories, maven, ivy, etc.

I have a simple eclipse java project that I build using gradle 1.2 with the following build.gradle file:

apply plugin: 'java' 

sourceSets {
  main {
    java {
      srcDir 'src'
    }
  }
  test {
    java {
      srcDir 'test'
    }
  }
}
repositories {
  flatDir {
      name "fileRepo"
      dirs "file://internal.newtwork.drive/folder/test"
  }
}

uploadArchives {
  repositories {
      add project.repositories.fileRepo
  }
}

Where in the gradle docs can I read about how to copy resources to a remote fileshare?

I have tried to update the protocol and the dir attribute based on the below answers but I get this error:

  • What went wrong: Execution failed for task ':uploadArchives'.

    Could not publish configuration ':archives'. java.io.FileNotFoundException: /internal.newtwork.drive/folder/test/sample-gradle-java-unspecified.jar (No such file or directory)

The destination is correct so does the flatDir repo not support networkdrives?

回答1:


You should define the following parameters:

archivesBaseName = 'yourappname'
group = 'your.app.package'
version = '1.0.0'



回答2:


Your URL doesn't mention a scheme (http:, file:, etc.). I don't know if you can get away with using a file: URL, or whether you need to us a different syntax to specify a directory rather than an HTTP URL, but either way, you'll need to correctly form the URI for the Windows UNC path.

See this question for more details.




回答3:


It looks like you're crossing your wires. The url would only be part of that ivy repository declaration which you're apparently not using. The filesystem repository would be handled by the flatDir block which is then referenced by the add project.repositories.fileRepo statement. I'd suggest trying the full path in the flatDir dir variable, otherwise the path of least resistance may just be to throw together a simple manual file copy (or other transfer) task which is then added on to the main deploy task you're using.




回答4:


//Try this,

apply plugin: 'java'
apply plugin: 'maven'

repositories {
    maven {
        url "$archivaUrl"`enter code here`
    credentials {
            username = "$userName"
            password = "$passWord"
        }
    }
}

// Dependencies
dependencies { 
    // specify the lib files at compile and run time         
    compile fileTree(dir: 'lib', include: ['**/*.jar','*.jar'])
    runtime fileTree(dir: 'lib', include: ['**/*.jar','*.jar'])
}


// source path 
sourceSets {
    main {
        java {
        srcDirs 'src'
        }

    }
}

uploadArchives {
    repositories {
    mavenDeployer {
        repository(url: "$archivaUrl") {
        authentication(userName: "$userName", password: "$passWord")
        }
        pom.version = "1.0-SNAPSHOT"
        pom.artifactId = "fd-common"
        pom.groupId = "com.somename.common"
    }    

    }
}


来源:https://stackoverflow.com/questions/12727783/how-to-upload-artifact-to-network-drive-using-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!