How can we publish an artifact to a local Ivy repository in Gradle? - ivy

In Gradle, we have configured a local maven repository, and artifacts are uploaded there for use in my local builds of other projects.
I'd prefer to use an Ivy repository (so I can have a custom pattern for artifact names).
How do you configure Gradle to upload to a local Ivy repository?

Try this (based on this and the API):
uploadArchives {
repositories {
ivy {
ivyPattern "/home/robin/.ivy2/local/[organisation]/[module]/[revision]/ivys/[artifact](-[classifier]).[ext]"
artifactPattern "/home/robin/.ivy2/local/[organisation]/[module]/[revision]/[ext]s/[artifact](-[classifier]).[ext]"
}
}
}
(replacing those patterns with your real ivy/artifact patterns).

Related

How to run corda enterprise

I just research about Corda enterprise, I have downloaded file Corda enterprise3.zip when I extract this file, in this has a lot of files jar. Who can help me explaining how to run corda enterprise and use it. Thanks
The JAR files are the Corda Enterprise dependencies for your node.
If you want to develop CorDapps against Corda Enterprise, you need to set your project's build.gradle file to depend on these dependencies. Do one of the following:
Option 1:
Place the Corda Enterprise binaries in your local Maven repository ( ~/.m2/repository on osX, C:\Documents and Settings\{your-username}\.m2] on Windows) and add mavenLocal() to your build.gradle file's repositories block.
Option 2:
Publish the Corda Enterprise binaries to a personal Maven repository and add the following block to your build.gradle file's repositories block:
maven {
url 'https://repo.mycompany.com/maven2'
credentials {
username "<username>"
password "<password>"
}
}
Option 3:
Place the Corda Enterprise binaries somewhere on your local filesystem and add the following block to your build.gradle file's repositories block:
maven {
url 'file://D:/path/to/local/directory'
}

How to publish libraries from Ivy cache to artifactory Ivy repos

We lost our ivy repository for 3rd party libraries (a lot of them). The only thing we have is the ivy cache sitting on a build agent. Now we decide to move to Artifactory, ivy:install can copy dependencies from a repo to another, but ivy cache is not a repo. In addition, the ivy cache keeps all versions of a jar file under the same directory (ivy cache default pattern) - [organization]/[module]/[type]s/ (no revision). But we'd like to sort them out into different directories - [organization]/[module]/[revision]/[type]s/.
After doing this, should the new repo in artifactory function the same as any other repository? In other words, do I miss anything by creating a repository in this way?
Any help is greatly appreciated.
You can create a new repository layout in Artifactory that will match the Ivy cache layout:
[org]/[module]/[type]s/[module](-[classifier])-[baseRev](-[fileItegRev]).[ext]
Then create a new local repository configured with the Ivy cache layout and import the content of your Ivy cache into the new local repository.
Finally create a new virtual repository configured with the default Ivy layout and include the local repository you created. The virtual repository will perform the transformation between the Ivy cache layout and the Ivy default layout. You will need to configure Ivy to resolve artifacts from the virtual repository. In addition you will be able to include other Ivy repositories in this virtual.

Create a Private Remote Ivy Repository

I've been doing quite a bit of searching and am unable to put all the pieces together. I want to create an ivy repository on one of our servers. I want to lock it down so it is private, and then be able to publish to this repository from Gradle.
I know how to publish using Gradle, and I have that working with a local ivy file system that Gradle creates:
repositories {
mavenCentral()
ivy {
name "localRepos"
url "${System.properties['user.home']}/repos"
}
}
uploadArchives {
repositories {
add project.repositories.localRepos
}
}
So what I need to do now is translate that into publishing to a remote private repos. But first, obviously, I need to create that repos and I can't seem to figure that out from the Ivy documentation or Google searching. Can someone point me in the right direction?
I'd prefer not to have to go down the Nexus, etc approach (no Maven).
An Ivy repository is just a file store, and hence you need to set up a server (e.g. Apache httpd) that allows to read and write those files (e.g. via HTTP GET/PUT). However, I strongly recommend to use a repository manager. Artifactory is a good choice.

Gradle script to move artifacts between Maven repos

I'm working on a Gradle script to copy an artifact from one Maven repo to another. I was trying to hack it by putting the artifact as a dependency and then us setting that as an archive.
I've tried using the configuration.files() method but I haven't been able to build a dependency object that it will accept.
dependencies {
compile group: artGroup, name: artName, version: artVersion
}
artifacts {
archives configurations.default.files(
/* I have not been able to build an argument this method accepts */
)
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: 'file:../../../repo')
}
}
}
We did this already in other environment (copying files from remote to local), and it looks like you got some misconceptions with Gradle DSL.
First the artifacts { archives {}} is used to ADD deployable artifacts to the archives configurations. You cannot use it (in term of doing something with the configurations files) in this block.
Second, you cannot upload what you resolved "as-is". Upload is for artifacts produced or manual added (they have a special type) by the build.
For us the solution was to create a new Gradle task "copyArtifacts" that actually copy all the files of resolved configuration into the local folder.
Hope this helps.

How can I get nexus to proxy springsource maven repository on s3?

I have nexus 1.5.0 setup to proxy springsource repositories but it's not working. The repositories are on s3 that nexus doesn't seem to understand how to deal with that.
What's the right pattern?
Here are the repositories I'm told I need, but I cannot access the maven paths with in them
http://repository.springsource.com/maven/bundles/release
http://repository.springsource.com/maven/bundles/external
Do, I need to mirror these locally?
According to NEXUS-1121, your version of Nexus knows how to deal with S3 based repositories. Below, Eugene's comment:
Here is Nexus setup that works for me:
Configured "proxy" repository for http://repository.springsource.com/maven/bundles/release
Configured "proxy" repository for http://repository.springsource.com/maven/bundles/external
Added both of those repositories into default "Public Repositories" group
After that I am able to download
artifacts from those repositories as
if they are in Maven Central
repository.
The only issue is that you can only
search trough artifacts that been
proxied, because there is no Nexus
index published on those repositories.
It should be easy to publish index and
instructions for using standalone
indexer can be found at
http://docs.codehaus.org/display/M2ECLIPSE/Nexus+Indexer#NexusIndexer-indexer
It works for me with this configuration and with another repository.
I have a Sonatype Nexus repository version 1.9.1.1. I wanted to configure the repositories to download artifacts from http://maven.springframework.org/milestone/.
I have created a new proxy repository with this configuration:
id: repository.springframework.maven.milestone
Name: Spring Maven Milestone Repository
Rep. Type: proxy
Provider: Maven2
Format: Maven2
Rep Policy: Release
Remote storage: http://maven.springframework.org/milestone/
Down. Remote indexes: false
Auto blocking: true
File validation: False
Checksum: warm.
I saved the data and the repository was created.
The strange thing is that when i try to use the "browse Remote" tab I can't list anything.
Important: After that I clicked on Public Repositories / Configuration and added the Spring Maven Milestone Repository to the ordered group repositories.
And finally, I wrote the dependency in my POM archive:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.0.0.RC1</version>
</dependency>
And it was downloaded without problems.
I hope it will be useful.