Force download maven-metadata.xml - maven

So my job has 2 parts. The first part downloads all the required maven artifacts from a central online repository. The second part uses the download folder as an online repository(by changing URL from central repo to local folder) to build our product.
But there are certain artifacts which do not have a maven-metadata.xml after the first part of the job. As a result, the second part fails. I don't want to hardcode the online repo and curl as it's not what we're looking for. Neither do I want to copy some other maven-metadata.xml and edit my changes. Also, I cant give the offline option during build, as I do need the artifacts to be picked up from my local repo(downloads).
Any solution to this? Thanks IA.

Related

bintray creating directories claims to upload artificats but it's blank

We are evaluating bintray and have the following build file
https://github.com/deanhiller/webpieces/blob/evaluateBintray/build.gradle
(not sure the build file matters since it reports that it is uploading each and every artifact correctly). I see stuff like this...
> Task :webserver-plugins:plugin-backend:bintrayUpload
Uploaded to 'https://api.bintray.com/content/deanhiller/maven/plugin-backend/2.0.19/org/webpieces/plugin-backend/2.0.19/plugin-backend-2.0.19-sources.jar'.
Uploading to https://api.bintray.com/content/deanhiller/maven/plugin-backend/2.0.19/org/webpieces/plugin-backend/2.0.19/plugin-backend-2.0.19-javadoc.jar...
Uploaded to 'https://api.bintray.com/content/deanhiller/maven/plugin-backend/2.0.19/org/webpieces/plugin-backend/2.0.19/plugin-backend-2.0.19-javadoc.jar'.
Uploading to https://api.bintray.com/content/deanhiller/maven/plugin-backend/2.0.19/org/webpieces/plugin-backend/2.0.19/plugin-backend-2.0.19.jar...
Uploaded to 'https://api.bintray.com/content/deanhiller/maven/plugin-backend/2.0.19/org/webpieces/plugin-backend/2.0.19/plugin-backend-2.0.19.jar'.
Uploading to https://api.bintray.com/content/deanhiller/maven/plugin-backend/2.0.19/org/webpieces/plugin-backend/2.0.19/plugin-backend-2.0.19.pom...
Uploaded to 'https://api.bintray.com/content/deanhiller/maven/plugin-backend/2.0.19/org/webpieces/plugin-backend/2.0.19/plugin-backend-2.0.19.pom'.
The really weird part though is it would create directories
https://dl.bintray.com/deanhiller/maven/org/webpieces/plugin-backend/2.0.19
but nothing is there until I deploy everything then the files show up. It seems kind of odd that the directories are created but there are no files in the upload phase. Then, my final question is, are these artifacts only available there, or are they published to jcenter or maven central as well. I can't really tell.
We are trying bintray to maybe switch off of sonatype because every time we upload, we get exceptions on sonatype(for last 4 days we have not been able to release). In bintray so far, every single upload has been successful(176 artifacts in one go).
Possibly I need more stuff to get this stuff out to jcenter or maven central?
thanks,
Dean
I do see these files at the moment.
If the artifacts are not published then only authorized users can view and download the content, this means that unauthorized users, such as anonymous, will not see content in your download repository.
Your package is not linked to jcenter therefore they are not automatically published on jcenter.
I would suggest to include your packages to jcenter.

How can i deploy changed files from teamcity into Artifactory?

I'm explicitly mentioning the file names under the custom artifacts path section to deploy the changed/ modified files to the artifactory. Is there any way Teamcity detects only the changed files and moves to the artifactory?
Is it possible to run a custom script for that?
If you are using TeamCity Artifactory plugin, then, the plugin is using checksum deploy, that means that, if I'll use your example, if you have 10 files that 7 were unchanged, the plugin will send the checksum of the file, if the checksum exist in Artifactory, it will not deploy it again but will only create a "pointer" in the database to point to that location. If a file checksum doesn't exist in Artifactory it will then deploy it to Artifactory.
I'm guessing here that this request is to save network traffic and build time, if I'm wrong, could you please share the need behind the question?

How do I get my local Maven to overwrite an existing artefact that was overwritten in my network repository

I have a Maven repository folder on our network drive, which contains all the artefacts we use.
Everyone in the office uses a standard settings.xml file on their local Maven setup which contains the location of that network drive as a remote repository.
In this way, we keep the network Maven repository folder updated so the local environment on everyone's computers simply downloads from that central repository folder, which avoids re-downloading off the internet for everyone.
We are busy developing a new library, lets say "MyLib 1.0.0". We install it into the central network maven folder repository, and everyone's local Maven projects use that dependency in their project(s). But now, we have not officially released "MyLib 1.0.0", its still a work in progress, so once we make further updates to it, we overwrite the "MyLib 1.0.0" artefact in the central repository.
Problem is, because all our local Maven's have already downloaded the artefact into their local Maven repositories, they wont re-download it. It already exists. I don't want to increase the version of "MyLib" yet because its not an official release, and I also don't want everyone to have to change their dependency version in their pom.xml files. I just want to replace the "MyLib 1.0.0" file and have everyone's local Maven's download and overwrite their local copy automatically. (At the moment everyone has to be told to go and remove the artefact from their local Maven repository manually, as which point it will re-download the latest copy of "MyLib 1.0.0")
What is best practice for the above, or how can I go about achieving this?
Based on your description there are comming two things into my mind.
First:
Stop using a network drive. Better start using a repository manager.
Apart from that a network drive is dammed slow.
Second:
In Maven a release is immutable which means if you have version 1.0 and deploy to your repository it will never being changed anymore. If you need to make a change on that you have to use a different version for example 1.0.1 etc.
You should start using SNAPSHOT's instead of releases if you are developing which is exactly causing the problem:
At the moment everyone has to be told to go and remove the artefact
from their local Maven repository manually, as which point it will
re-download the latest copy of "MyLib 1.0.0"
Which shows you are working against the concepts of Maven.
And third. It sounds like you don't use a continious integration for your builds.

how to backup/restore maven local repository

since it's sometimes really slow to download jars from a maven central repository, I want to backup my local maven repository and restore it in another computer and maybe even in another os.
I'm working in windows 7 now, so, do I just have to simply zip all the repository files in "C:\Users[username].m2\repository", and unzip it to the rep location in another computer to restore it? Or do I have to do something special?
Thanks for your answer.
As far as i know that is all you have to do, maven does not store any special information in the repository. If you do this frequently, you could also use something like rsync to reduce the time and load of this.
And if you have many machines that need basically the same set of jars, consider using some local repository, like for example Artifcatory. You can set it up to work as a transparent cache, plus you can deploy your own artifacts on it.
You can just make a zip and copy it on another system. If you can't unzip the archive in the default maven repository location you can set the new location in your settings.xml
I would suggest to download an Repository manager like Nexus, Archiva an use that. So you can just drop your local repository and it will be downloaded the next time you build.

Maven - Download Files/Folders

I am searching for a Maven plug-in that would help me download project artifacts. For example, I've a remote location, with the following directory structure:
Directory-A
Directory-B
artifact1.jar
artifact2.jar
Directory-C
artifact3.jar
artifact4.jar
All I want to do is when I specify Directory-A/Directory-B, it creates the structure locally and downloads all the artifacts from the remote location to the local structure.
Is that possible in Maven? The closest that I got is via maven-download-plugin, as suggested in this SO answer. However, this plugin lets me download individual artifacts (or as far as I understood from the usage documentation).
Thoughts, ideas? Any help would be really appreciated.

Resources