I got the Eclipse EE and realized it did not have maven/m2e, so I got m2e installed.
Then I am setting up projects and using pom.xml I start getting all the fun errors like:
Could not calculate build plan: Plugin....,
__ or one of it's dependencies could not be resolved: Failed to read artifact descriptor for ....,
Failure to transfer .....
Since I'm in a corporate environment, I find the IE setting and go find the PAC ( proxy auto-configuration ) script.
Then I enter those values into a in my settings.xml area.
I even tried some of the ideas shared by developers, such as deleting .lastupdated files and deleting directories.
Even though it totally defeats the whole idea of maven, I'm considering transfering all my .jar & .pom files from another machine's repository.
No joy yet. Something is still wrong, I just don't know what yet.
I seriously need some debugging or logging or a ping test, if there is anything available to discover what the problem is.
I found some great posts on Maven and Proxy. keywords: maven, m2e, 'failed to transfer', pom.xml, settings, proxy, etc.
also
Cannot download maven dependencies through proxy
http://jira.codehaus.org/browse/MNG-5237
after reading this, and not knowing if my company was using NTLM, I put in the wagon lightweight jar and referred to it with in pom.xml
How will I know, If I do end up needing this ?? and
where should I put the .jar file ? in the user repository area, or deep in the maven runtime \jars\ directory ?
Along the way, some questions also came up.
( for reference, I am on WinXP )
With an m2e only, do I need a $M2_HOME defined ? I'm thinking not, since I don't know where that would be.
related: With m2e, will I ever have a global settings.xml ?
Should the ${user.home}.m2/repository be referenced (and uncommented) in the local settings.xml ?
As a substitute for the command line maven, can Eclise 'Run Configurations' really be a full replacement ?
I know the dialog box you use, has the empty list of goals, when it should be populated, but you can always type in
What about using 'mvn -X'
Or any of the other cool maven commands, like the one that shows you all the transitive dependencies.
Still searching, but Thanks In Advance for anyone who can assist in resolving these Proxy issues.
Related
I had a NoClassDefFoundError problem with some test, launched from IntelliJ. In order to repair the situation, I had to make several changes in many poms of the project - adding new packages and excluding some old ones for to escape the overlapping of them. Also, I reapired the situation with different versions. But the situation did not improve. Again, some package, declared in pom, was not found where it should be.
I refreshed the maven repository by
mvn -e clean install -U
, as is advised in https://stackoverflow.com/a/9697970/715269 - so old and upvoted answer, that it surely looks as Santa.
The problem remained unchanged.
I output the maven map. It was correct and it contained all needed.
I looked at the list of the External Libraries of the project. It was the old uncorrected list of overlapping jars with same names and different versions, and without good packages I added just now, and well seen in maven tree output!
Already hapless,
I reimported packages in IntelliJ
by:
Ctrl+Shift+A, Reimport All Maven Projects.
Ho! The list of libraries got repaired. And the problem, mentioned in subj, disappeared.
The question is: How it could happen, that the same project has that very pom for everything, but gets packages differently being launched in maven and in IntelliJ?
I know about that feature "delegate IDE build to Maven". And I keep it turned off. But I am NOT talking about the different SW for building. Whether they are different or not, they should be up to the actual pom's. And whereas maven, if turned off from the automatic building won't know about changes in poms, IntelliJ KNOWS about them. It could have jars up to pom, or up to maven - it has sense, but it simply has some old rubbish. Was there some deep thought under that construction?
Every time you manually change the pom.xml file, including the dependencies you need to load these changes into IDE. IDE does it on Reload from Maven action. See also Import Maven dependencies.
Intellij doesn't use maven to bulid and run a project except you are delegating build and run action to maven:
Since, IDEA doen't really use maven to run and build, it uses the pom.xml to import the project structure and "tries" to build the project the same way was maven does.
Actually, there are quite a few differences between these to build processes.
Generating sources or filtering resources (don't know if this is still an issue) aren't done during building the project with Intellij IDEA.
In case you are using code generation you have to build the project via maven first and then - when all the resouces are filtered and additional sources are generated - you are able to run, debug aso. the project with Inellij IDEA.
That's an important thing to be aware of and that's the reason why maven and IntelliJ IDEA project structures might get out of sync.
You can enable the "Reload project after changes in build scripts" feature and select the Any changes checkbox to keep your project structure updated:
Why should you disable this feature anyway
If you are working on a build file (gradle or maven is not important) reloading the structure on any change can be very anoying. It's cpu intense, dependcies are fetched aso.
Therefore, I prefer to reload project structure only in case of an external change. This happens when pulling an updated version of the build file for example.
I need to convert few projects from ant to maven. I know the basics of both, also read a lot of articles on how to. However, is it a good idea to write a pom using eclipse? Or is it better to write it without using eclipse? The M2Eclipse plugin needs maven to be tweaked more, will the changes related to M2Eclipse cause problems when the war is built on jenkins?
Pros of using Eclipse IDE:
The formatting of pom.xml will be taken care, when you add the 'maven-eclipse-codestyle.xml' to the code formatter, as mentioned here. Formatting will be harder when you do it without an IDE.
The auto-completion feature of eclipse will make your coding easier, since it will automatically sense the open tags and close them. You need to close all the open tags manually, if you don`t use an IDE.
You can view the dependency hierarchy of the dependencies added and hence it might be a bit helpful while managing the dependencies.This can be extremely useful ,when you have transitive dependencies (Dependencies within other dependencies). You can find more about transitive dependencies here.
An IDE will warn you of common mistakes that may occur while coding (something like, 'forgetting to close an open tag','placing a tag in an incorrect location'). This will save a whole lot of time. If you don`t use an IDE, you need to correct the mistakes only when you get an exception after executing a maven command.
Eclipse will warn of missing artifacts (when the dependencies are not present in the local repository), which can help you to fix it before executing the maven goal.
Cons of using Eclipse IDE:
m2e plugin will throw 'Plugin execution not covered by lifecycle configuration' errors all over your pom.xml files. These errors won`t affect your build, but may be quite annoying.
I personally have done migration from Ant to Maven2. IMO it is better to write pom.xml on your own so that you wont face any last minute surprises as well as you will get complete overall knowledge on what you are exactly doing with your pom file.
However if you still want to go with m2e, from my experience it did not create any problems at all. Regarding the build - I guess there shouldn't be any issue. You can refer this link if you need more info about m2e and jekins - m2e and jenkins
I am very new to maven, artifactory and jenkins as well. I made a directory 'repository' under path /home/apache-maven-3.2.1/.m2/repository. I am trying to deploy a jar through artifactory UI into this directory. Please suggest some configuration so that i can do this. Jars which i deployed already were deployed successfully but when I see inside repository, there is nothing in it.
One other question is how to set dependencies while deploying any artifacts?
These questions may be silly because i don't know anything about the above three tools and i am unable to set relation between them also.
Thanks in advance.
I'm also quite new to maven and still struggling with it, but the thing to do is try to configure a pom.xml file with your settings. Since you didn't give any indication on how the jar file has to be build, you got to find a guide in order to do it.
Useful links:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
https://www.tutorialspoint.com/maven/maven_pom.htm
Hope this can help!
I'm working through the tutorial here for using Maven under IntelliJ:
http://wiki.jetbrains.net/intellij/Creating_and_importing_Maven_projects
I'm up to the 'working with dependencies' section. I try to add a Maven Dependency using Maven Artifact Search. In the 'search for class' tab, nothing shows up, no matter what I type in the search box. Under 'search for artifact', about two dozen dependencies show up at the start.
Most of the discussions about this type of issue suggest a problem with Maven settings in IntelliJ. I confirmed that the Maven home directory is set properly. Under 'Repositories', the http://repo1.maven.org/maven2 URL is there and I was able to update it.
I used search.maven.org to double check that searching by class name does produce a result for the value I search for, "TestCase". I am using Maven 3.1.1, Windows 7 x64, JDK 1.7 64bit.
Update:
Maven works, i.e. goals can be run and they will download dependencies and build the project, if I edit pom.xml manually. However the Artifact Search cannot find any class, ever. I included a screenshot of what shows up when I use Artifact Search to search for artifacts. (Link to my image does not seem to appear even though I uploaded right to SO, not sure why... maybe imgur is blocked at my location)
Please navigate in Settings to Project settings -> Maven -> Repositories
Then find repo1 on your list and click "Update" - that will rebuild your repositories indexes and search for class will work
FIXED:
I got an idea from reading this question discussing what a snapshot is and why it is not usually updated.
Force Intellij IDEA to reread all maven dependencies
I went into IntelliJ Settings -> Maven and enabled "Always Update Snapshots" and I also changed "Plugin Update Policy" to "Check For Updates". (Even though I don't know exactly what that second one means, and IntelliJ says it's not important for my version of Maven anyway)
Immediately I was able to locate the ServletContext class in the Artifact Search. This is before I even updated from repo1 on the Repositories screen.
I can't really say why this did the trick but it seems to have worked. Thanks to #JakubK for helping me explore toward the solution!
Certainly this is the sort of issue that leads one to consider giving up (and starting to reinstall things...!), hopefully this helps someone else at some point.
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.