I am setting up a local repository using Apache Archiva. After setting up now I need to copy the libraries that got downloaded into my local maven repository into archiva. Currently I am manually copying it but it is very tedious process and I am planning to automate it using some scripts. Is there any better approach to do this?
I'm trying to write a plugin for this here which is able to copy jars and poms for all dependencies in all Configurations (including transitive dependencies). You might be interested in this code
Note: I've got a failing test here because I can't currently get the parent pom xml via the Gradle API's. I raised a feature request in Gradle here
There's a suggestion on the issue to use the IvyPot plugin... I haven't tried this myself but might be worth a shot.
Related
I am trying to implement a little service in Scala using Maven to manage dependencies and I would like to add webhdfs-java-client that I have found at https://github.com/wdavidw/webhdfs-java-client
I have added to pom.xml following code:
<dependency>
<groupId>org.zxs</groupId>
<artifactId>webhdfs-java-client</artifactId>
<version>0.0.0</version>
</dependency>
It does not work, as I have expected. Does anyone could give me an advice if there exists some catalog of maven repositories (something like pip for Python)? And what can I possibly do if I'll not find this library in the catalog? Is it possible to somehow add it to maven manually?
In maven world you can install this dependency locally and resolution will be done via local cache (the one that usually resides in ~/.m2). Steps are as simple as mvn clean install in that repo. Having said this, it wouldn't resolve problem for your users (transitive dependencies, you know), which is why you likely need to publish that dependency somewhere (or ask library author whether it's published somewhere).
SBT, which is scala's de-facto build tool allows you to depend on other sbt flavored projects simply by referencing their git repository, but sadly, maven has no such feature.
I tried all the suggested solutions which found on Stackoverflow but didn't solve the issue with Maven repositories in Intellij IDEA. The problem is that I can't find needed jars in local repository, even if I update it. Central repository is impossible to be updated. Just for example: I use in web-app servlet api (jar is found in local repo but the version is 2.5), jstl and jdbc. If I don't create Maven project I just add all the external libraries to the project manually. But in the case of Maven-project I do not add nothing but try to create dependency through Alt + Ins when writing the class. Result - there are not needed jars in local repository.
What I tried:
1.Installed/deleted a couple of versions of Maven (The current is 3.2.2)
2.Defined local repository in settings.xml (the tag missed by default)
3.Updated local repository
4.Added dependency manually in pom.xml but IDEA didn't define it
Moreover, when I created a first Maven-project in IDEA according to web-app archetype it didn't have needed folders structure but started donloading the number of jars. Current version of IDEA is 13.0. If somebody faced such problem please help me to eliminate it.
But in the case of Maven-project I do not add nothing but try to
create dependency through Alt + Ins when writing the class. Result -
there are not needed jars in local repository
You actually have to perform an maven install, this downloads the jars from whereever to your local repository. Just writing the depenecy in pom, doesn't actually download them.
This is how maven works, nothing to do with intellij.
For Example you are using this library and sometimes later this library no longer exist in maven so what happens to your project?
Can we be able to continue developing that project using this kind of remote library? or we need to replace codes that uses this library?
dependencies {
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
}
If you are talking about a dependency like the above which is in Maven Central the dependency will never be deleted in Maven Central, cause you can't delete artifacts in Maven Central.
If the depenedency is comming from somewhere else you might better duplicate the code into your internal system or the best solution would be to use a repository manager which contains every artifact which you ever used and you can backup this system without the need of Maven Central. Thinking of breaking network connections or something similar.
I guess the easiest would be to simply clone this library:
git clone https://github.com/chrisbanes/Android-PullToRefresh.git
and push it to your github account Pushing from local repository to GitHub hosted remote
I'm wondering if there was a way to get the sigar compiled binaries ie. libsigar-universal-macosx.dylib etc.. using maven. i know that i can just manually add it but I wish to automate the deployment
In maven there are lot of way to arrange your build
Consider the following options:
Quick and dirty: Make dependency of scope 'system' put the library in the predefined place and build.
Read about the system scope here
Much better approach although requires more work: create a maven repository with the thirdparty jars that you don't have in repo 1. Although you can use http server like apache and provide an http based access to such a repository, I would recommend you to use the proxy that was build exactly for this purpose. Consider to use Nexus or Artifactory for this.
Then configure these repositories in the maven installation (all the sigar jars will be managed by this repository) and build your project.
Hope this helps
I'm new to Maven, using the m2e plugin for Eclipse. I'm still wrapping my head around Maven, but it seems like whenever I need to import a new library, like java.util.List, now I have to manually go through the hassle of finding the right repository for the jar and adding it to the dependencies in the POM. This seems like a major hassle, especially since some jars can't be found in public repositories, so they have to be uploaded into the local repository.
Am I missing something about Maven in Eclipse? Is there a way to automatically update the POM when Eclipse automatically imports a new library?
I'm trying to understand how using Maven saves time/effort...
You picked a bad example. Portions of the actual Java Library that come with the Java Standard Runtime are there regardless of Maven configuration.
With that in mind, if you wanted to add something external, say Log4j, then you would need to add a project dependency on Log4j. Maven would then take the dependency information and create a "signature" to search for, first in the local cache, and then in the external repositories.
Such a signature might look like
groupId:artifactId:version
or perhaps
groupId:artifactId:version:classifier
This identifies a maven "module" which will then be downloaded and configured into your system. Once in place it adds all of the classes within the module to your configured project.
Maven principally saves time in downloading and organizing JAR files in your build. By defining a "standard" project layout and a "standard" build order, Maven eliminates a lot of the guesswork in the "why isn't my project building" sweepstakes. Also, you can use neat commands like "mvn dependency:tree" to print out a list of all the JARs your project depends on, recursively.
Warning note: If you are using the M2E plugin and Eclipse, you may also run into problems with the plugin itself. The 1.0 version (hosted at eclipse.org) was much less friendly than the previous 0.12 version (hosted at Sonatype). You can get around this to some extent by downloading and installing the "standalone" version of Maven from apache (maven.apache.org) and running Maven from the command line. This is actually much more stable than trying to run Maven inside Eclipse (in my personal experience) and may save you some pain as you try to learn about Maven.