How to upload artifact to network drive using grad

2019-07-13 12:00发布

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?

4条回答
再贱就再见
2楼-- · 2019-07-13 12:10

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楼-- · 2019-07-13 12:10

//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"
    }    

    }
}
查看更多
该账号已被封号
4楼-- · 2019-07-13 12:17

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.

查看更多
Ridiculous、
5楼-- · 2019-07-13 12:29

You should define the following parameters:

archivesBaseName = 'yourappname'
group = 'your.app.package'
version = '1.0.0'
查看更多
登录 后发表回答