Recently I have upgraded maven from 2.x to 3.x and then deleted the total .m2 repository from Users and again generated .m2,
Everything looks good but I want get the confirmation from repository should these all are generated using maven 3.x.
Can some one help me out?
In order to make sure that the dependencies are downloaded through your new maven version. You can add a dependency, which does not exist in your local repository, through your new project, which uses maven 3 and you run the mvn clean install command in the path, in where you parent pom is and then, you can check whether this new dependency in your local repository or not. However, as SiKing said, the content is independent from the version of the maven. You can make a small test like i described.
Related
I have a legacy project that I'd like to convert to a Maven project for dependency management.
The problem is, that I have one jar (fop-1.1.jar) that I had to edit. It differs from the one that is publicly available and I only have it locally. But I need it this way.
What I tried to do, following several similar how-to's, it to create a fake Maven repo inside the project (local repo is no good, because several people work on that project and the solution has to be self-contained on Git) and reference this repo from the pom.xml. Sounds like the way to go for me, but it doesn't work. Eclipse show the project repo grayed-out :(
What am I missing?
BTW: this is what I tried to follow: https://devcenter.heroku.com/articles/local-maven-dependencies
Let me suggest another way: When we need to "edit" a jar, we give it a special version number like 1.1-edited instead of 1.1.. Then we can easily upload it to our normal Maven repository and use it. Maven even makes sure that you do not accidentally load both versions in the same project because the edit is only in the version number.
I guess what you need is a private maven server(I guess it exists), and then execute command to deploy jar( before deploy, check your account has privileges)
mvn deploy:deploy-file -Dfile=${jarFilePath} -DgroupId=${groupID} -DartifactId=${artifactId} -Dversion=${version} -Durl=${privateServerURL} -Dpackaging=jar -DrepositoryId=${privateServerURLInYourMavenSettings.xml}
,
after deploy successfully, add maven dependency
<dependency>
<groupId>${groupID}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</dependency>
When we do mvn install deploy to a repository ${repository-jars} these dependencies can be used by others as intended.
When we afterwards upload sources to another repository ${repository-sources} the dependencies are no longer resolved correctly.
mvn deploy:deploy-file
-DgroupId=foo
-DartifactId=bar
-Dversion=1.0-SNAPSHOT
-Dfile=target/bar-sources.jar
-Dpackaging=jar
-Durl=${url}
-Dclassifier=sources
-DrepositoryId=${repository-sources}
Everything looks correct in nexus and both repositories are available in a regular Repository Group.
The hypothesis is that maven tries to use the latest uploaded artifact and ends up downloading the sources jar instead somehow ignoring the classes modifier. This is verified by first uploading sources and then do a maven deploy where it works as intended.
What is the correct way that allows us to upload sources in a separate job that runs after a deploy?
In examination, Maven is creating two different snapshots, and when you attempt to get latest, it's getting the newest one (which is sources) from the Group you've setup.
What you might actually try is putting them in the same repo, and separate them using Content Selectors. This is our newer version of Repo Targets from Nexus Repository 2.
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.
I am trying to setup a Maven Nexus Server for my firm to share common JARs that we build inhouse. I use my workstation (call it workstation 1) to build the common JAR and I then do a mvn deploy to deploy it to the Nexus Maven Server. Then I add it in the dependencies in the pom.xml of the project that needs it and I do my mvn package and everything is great.
Now if I change the common code and I run mvn deploy with the same version number and then rerun the mvn package on the second project, it will see the changes and everything is great.
Now lets move to workstation2. If I do a mvn package on the project that needs the common code everything is fine. But if the common code changes and I rerun the mvn package command it looks like it's going to my local repository on the workstation and using that version, not the new version in Nexus!
So my questions are the following...
Does mvn deploy save a copy in the local repository before the nexus repository?
How do I make the project check the nexus repository for the most up-to-date file before the local repository on the workstation?
The code is a accept SNAPSHOT so I would like it to be updated each time the user try to access it.
1) maven consult the local repository and only for a miss it aks the online repository (nexus)
2) I do not know
Anyway: (Except for SNAPSHOTS) you should not modifiy a released artefact without updating its version too!
You can run mvn -U package. With -U Maven will always check the repositories (in your case Nexus) for newer SNAPSHOT versions of your dependencies.
You can also add a configuration to your settings.xml to look always for new versions of dependencies. See the Settings reference, the configuration is named <updatePolicy>always</updatePolicy>
I got it.. I had to add always to the snapshot settings in my settings.xml
I am having a java project with a ant build file, using this ant file i create an ejb of the project and deploy it on the jboss server.
Now I am planning to use maven and convert this existing project which consist of nearly 28-30 jar's in its class path(jars related to ejb3, hibernate, jboss, etc).
I can easily do it using eclipse i.e right click project goto maven and click Conver to Maven.
A pom.xml is generated and the MavenClassPath Container is also added to the project.
Now I want to know how to get rid of those 28-30 jar's present in the lib folder of the project and in the classpath. i.e. I want my pom.xml handle all the dependencies.
Does Maven provide any mechanism to achieve this goal while converting the project or I have to add all of these jar dependencies one by one manually in the pom.xml file.
The intention of doing this is I want to have common maven remote repository where the jars will be stored and each developer machine will point to it through their maven project.
Thanks
I think you're after a repository manager like Nexus (I use Nexus, it seems to be the most popular http://nexus.sonatype.org/ ).
Nexus can be used as:
A proxy repository (for Maven Central, etc)
A repository for your own releases.
Nexus provides user management for your developers to release builds into the repo.
Developers will then point their Maven settings.xml file to your Nexus repository, and all their dependencies will come from here (Nexus will cache them).
I'm afraid you will have to configure the dependencies individually, but that is a good thing, because you should pay attention to what version ranges you are interested in for each dependency.
Any jars which can't be found in Maven Central, etc, you can add to your own Nexus repository .
Ofcourse there are alternatives to Nexus, but I haven't used any.
HTH
The most important thing i can recommend is to use a Maven Repository Manager (Nexus, Artifactory or Achiva or other..).
Second your pom conversion via Eclipse shows me that you are not using an up-to-date Eclipse nor an up-to-date Maven Plugin for Eclipse. The best thing would be use Eclipse-Indigo (m2e is the newest and greatest).
Furthermore you have to go through all your jar's and add them step by step to you pom (dependencies) and see if your project can be compiled. This should be checked on command line not inside Eclipse.
After you got a working pom.xml file put it into your version control and check if you can remove some of your added dependencies based on transitive dependencies. After that you can finally delete your lib folder.