broken classpath with Intellij Idea on maven dependency - maven

i'm using Intellij IDEA 12.1.6, almost everyone in my company use Eclipse and dont notice my problem. We have a local nexus repository where we deploy artifacts, but some of them are systematically created with an invalid maven-metadata.xml (the latest snapshot timestamp and build number does not match the effective artifact name on repo) and intellij ends up telling me those libraries have broken classpath.
Is there a way to force intellij on hooking the maven jars on my local repository without worrying about those metadata additional information? Eg eclipse hook the jar in his classpath taking the version which does not include those data (in my m2 repo dir i see both 2 jars downloaded, the one with full data and the other one without them)
eg.
library-0.0.6-SNAPSHOT.jar
library-0.0.6-SNAPSHOT-20131028.111135-10.jar
Thank you for your help.

If Importing the eclipse project did not work. You should be able to Configure the library contents . The step for Configure Library Dialog should allow you to point the library to a different location.

Related

Maven build using embedded JAR in project pom

I am working on a Maven project where a build is done through Jenkins, and 1 particular JAR has been removed from corporate repository recently.
So my build is failing as parent pom.xml is referring to a JAR not available in the repo.
But I have the old certified copy downloaded in my local repo, and I want to use the same JAR during build copying in the project folder and want to use the local copy of dependent JAR in pom.xml instead of downloading from corporate repository embedded in the project structure.
How can I do this?
Frankly, this does not sound like a good idea.
While it is possible to reference jars with the <systemPath> entry, it is generally considered bad practise.
By "corporate repository", do you mean a repository of your own company or of some other company? In the first case, you should request that the jar is put back in. In the second case, it would be better not to use the external corporate repository directly, but to set up your own Nexus/Artifactory through which you use (different) external repositories. This Nexus/Artifactory can then host additional artifacts like the one you need (you can e.g. upload them through the UI).

Checkout maven dependency as module in IntelliJ IDEA

I have a maven project that is broken down in a bunch of dependencies, some of which I have RW access to the version control repository.
I'd like switch one from being a read-only dependency to a full project module. Is it possible for IDEA to use the data contained in the POM to do this? I heard that NetBeans does this.

Maven and ibiblio

I searched a lot in apache documentation and ibiblio.org and I could not find a decent straight answer.
My questions:
When I download a jar using maven dependency (setup in pom), how can I be sure that the file does not change on the remote repository? for example, if I'm using log4j version 1.2.3, downloaded from ibiblio.org (or any other repo for that matter), how can I be sure I'm getting the exact same jar each time?
Does maven delete jars from the local repository? let's assume I'm not clearing the repository at all, will it fill up eventually? or does maven have some kind of mechanism to clear old jars?
In Maven conventions a released version like log4j 1.2.3 will never be changed. It will be left in your locale repository until you manually delete it. It can't be changed by anyone except for the admins on maven central, but i suppose they don't do such a stupid thing.
Furthermore the download by default is done from maven central (repo1.maven.org/maven2 instead of ibiblio).
One of the "tricks" in Maven is download an artifact (released) only once...that improved your build performance in contradiction to the SNAPSHOT dependencies.
You could configure your own repository, and point all your project poms at that. It's easy to configure your poms to use a different (private) repository, but I've never set one up myself. Doesn't seem too hard, other than managing it to keep all the needed artifacts available.

How to make my maven project depend on non maven projects?

I want to create a maven project, which has to depend on a non maven project which in turn depends on 2 other non maven projects. I do not have ownership of any of the other projects and it would not be possible for me to change anything in those projects let alone the structure to conform to the maven structure.
I asked if I could just get jars -- but was told that because of multiple levels of dependency, it would be "difficult" -- although I haven't understood why.
Is this possible or should I just abandon the use of maven to create my project and go with a regular project with jars in the lib folder?
Inxsible
If you can go with a regular project build that means you must have access to the other project's jar files?
It doesn't really matter how the other project builds them, you can still gain more control over your own build process by loading the jars you depend on into a Maven repository.
I'd suggest using one of the following repository managers:
Nexus
Artifactory
Archiva
They'll give you management screens to uploading 3rd party jars, they'll also a more efficient way to use other Maven repositories like Maven Central.
Once you've got your Maven build process working, you could encourage the other projects to automatically publish their versions into your Maven repo.
They could use the ANT tasks provided by the Maven or Apache ivy projects. Worst case you just continue to load their libraries until they see the light :-)

How to enable inside glassfish access to maven repository?

I have a following problem. We have a central maven repository hosted on our company server. Our team is working on a project. Everyone here uses that repository to get the required artifacts. If something is missing at the moment and is required for the task that the developer is currently dealing with, he installs this artifact manually to the central repository, so that his commits don't break the automated builds.
Now, each developer also has Glassfish v2 installed on his machine. That is for testing and debugging purposes. Before committing the changes, developer makes the .ear for the project with Maven help. However, after the developer deploys the ear to it's local glassfish, frequent errors arise, because the set of glassfish libraries may not contain all the latest dependencies of the central company repository.
Right now in case of the error the developer simply reads the log and looks what exactly is missing. After that he manually copies the required jar inside his local $GLASSFISH_HOME$/lib dir. But that seems a little bit frustrating. How can this be done automatically?
Right now we are trying to implement the following solution. The developer has to synchronize his local maven repository gathering all the artifacts from the central one that are required by the project. This local repository has to be placed on the java classpath, so that glassfish would also see it. Is that a correct approach? Maybe there is a way to install directly all the required artifacts from the central repository inside $GLASSFISH_HOME$/dir and this can be done automatically during deploy?
About having to install dependencies. If the developers need to install dependencies missing from public maven repositories, take into account that usually maven proxies have the ability to cache public repos. For instance, archiva has a proxying cache. If the dependencies are your own project deliverables you should consider releasing and deploying with maven to your company repo.
About latest versions. You need to specify maven what version of dependencies should use. I would prefer editing my poms manually, anyway there's a variety of ways to achieve that.
The libraries should be part of the project, I think. If not standard libraries of glassfish, they should be included, for instance, in your war file as part of your project. If not standard but not part of your project (not the regular approach) consider managing this glassfish as a project on its own (own git/svn repo, own pom, own versions, own everything).
Good luck.

Resources