build error after importing maven projects - java

I cloned one of the open source git repositories and was trying to import it as maven project in eclipse. After I imported everything as a maven project, whole package is getting messed up. See the below error:
How can I fix this issue so that I can build it on my local box? I cloned the same git repository locally on my desktop.
I am using eclipse version:
Eclipse IDE for Java Developers
Version: Luna Service Release 1a (4.4.1)
Build id: 20150109-0600
Steps I have tried already:
I have already tried maven->update project.
I have also tried removing and adding it again.
I tried mvn clean install both on command line and eclipse, they are successful as well.
Can anyone help me with this? If needed, you can also clone it and try importing it to see whether it works for you or not.

The root of your problem is that the build section of the pom.xml for that project specifies:
<sourceDirectory>./src</sourceDirectory>
Eclipse uses the sourceDirectory tag to tell it where the root of the main sources are. If you change that to ./src/main/java, then right-click on the project > Maven > Update Project... and click Ok (I had to do this twice) it will fix the Eclipse classpath so Eclipse can build the project. You can then revert the pom back to the head revision and so long as you don't run Update Project again it should continue to build.
I'm unclear on why that project specifies a non-standard source directory but uses the standard Maven layout, but this should at least get you into a working state within Eclipse.

Related

Unable to import the Maven module in Intellij

I am trying to open this module in Intellij:
https://github.com/eugenp/tutorials/tree/master/javaxval
The steps followed by me:
Go to required directory javaxval/ in my local and
mvn clean install.
Open the pom.xml inside javaxval/ and open it as a project.
But Intellij is not syncing with the libraries mentioned in pom.xml as I can see in libraries section in Project Structure settings. Also, because of that, I can see lot of compilation errors.
Any idea what is the issue I am facing and how can I fix it?
This project imports and builds fine in IntelliJ IDEA 2019.2.2 version using the bundled Maven 3.6.1 for importing and JDK 1.8.
If it doesn't import/build for you, perform the diagnostics and check the logs as described in this answer. Make sure the parent pom file is present in the directory tree on your disk.

Problems with IntelliJ at cloning repo from github

I am new to github. I tried to clone a repo and then pull the files on my computer. All the other team members did the same thing and it worked for them. When i open the project with Intellij all the .java files look like this:
files
It also says that my SDK isn't set.
I tried to set my SDK, and also i tried to set the java directory as 'sources root' because someone said that is a problem with the project structure.
These problems disappeared but then IntelliJ didn't recognize that my project is a maven project so i had to add manually the file pom.xml and refresh maven.
Then this problem disappeared but i had another:
"Cannot start compilation: the output path is not specified for module 'cmsiss'.
Specify the output path in Configure Project."
I tried to set it from project structure but now I have this error:output error
Please help.
Open maven project using pom.xml file. File->Open->pom.xml
Sources should be pointed to project root, not java directory.
Give these a try.
The usual steps that I follow to open the project:
git clone <github clone url>
Open the project in intelli J using
File<Open
and browse to open the root of the project.
This should work fine but if it does not, a few more things you can try:
Try making the project root as a maven module
You can open the Project Structure to make sure you have Java SDK set up properly. It should show the java version you are using there.
Worst case, that is if nothing else works and if the project is not too big, just create a new maven project and make sure it runs, then add all the project files.
I pulled the project again and started from zero. I specified the SDK and then I opened the Maven project window and added a maven project (selected the pom.xml file) and refreshed it. Maven did it's job and created the project structure and all the stuff I've tried to do manually and finally worked!

Maven dependencies not visible under Build path in Eclipse Luna

I'm using Eclipse Luna for my project. I've imported a Maven project into it. Right click->import->import existing maven projects. I made mvn clean package install under run configurations. It ran successfully till mid of project, and in the sub modules, it got failed due to some issue in Java file. But whatever the JAR's that have been fetched should be displayed under Maven dependencies under Build path right?
Here is the screenshot
Do I require to make any steps here?
Right click the project and Configure as Maven project

Maven missing classes

I created a basic maven project in eclipse and I'm getting errors in my pom.xml that classes are missing, I checked the folder that it was looking in and the file paths don't match what I have and the classes don't exist.. My path goes up to: C:\Users\user.m2\repository\org\apache\maven\shared and it is stating there is a /filtering/ folder which I don't have. I have the latest maven and m2eclipse installed.
Most probably a bad installations (incomplete download or missing jars). I suggest you delete the
C:\Users\user.m2\
folder completely and run mvn clean install again. Maven will fetch the jars for you. Also try to refresh the maven project from within eclipse. Right click on project -> maven -> update project. Sometimes eclipse has this issue.

Added Maven dependency, Eclipse doesn't see it

I add guava 17.0 to my pom.xml, Eclipse automatically rebuilds project.
Ran mvn dependency:resolve, maven shows com.google.guava:guava:jar:17.0:compile in the list of resolved files.
However when in Eclipse I try to auto-complete com.google.g, it says "No default proposals". I've added dependencies in my pom.xml before, run mvn dependency:resolve and Eclipse picked them up immediately. What's different this time?
I've tried the following so far:
Tried cleaning the project and letting it automatically rebuild.
Clean, auto-rebuild, re-start Eclipse.
mvn clean followed by mvn install
https://stackoverflow.com/a/6913992/91933
https://stackoverflow.com/a/12978632/91933
https://stackoverflow.com/a/2393810/91933 (although I couldn't get Eclipse to accept $HOME/.m2 as the Maven repository (which it is)).
I can see target/<projname>-1.0-SNAPSHOT/WEB-INF/lib/guava-17.0.jar.
My configuration:
OS: OS X 10.9.3
Maven: 3.1.1
Eclipse: Kepler (with m2e 1.4)
The suggestion by #khmarbaise works best and solves all problems.
Just delete the project from Eclipse.
Re-import as "Existing Maven Projects" and point it towards the directory that contains the project's pom.xml file.
Let Eclipse's m2e plugin handle the rest
Worked flawlessly for me.
The following advice (taken from https://developers.google.com/appengine/docs/java/webtoolsplatform#maven) may only apply to GAE projects, but seems like it should be generally applicable (my project is GAE, so can't be sure):
The directory at the root of the Maven project must not
contain any of the following:
1. A subdirectory named target
2. A subdirectory named .settings
3. A file named .classpath
4. A file named .project
In file pom.xml inside < dependency > seleneium maybe you have defined < scope> test e.g. < scope>test < /scope>.
Removing/deleting this also can solve your problem.
At first, remove projects as markvgti suggested. I did this three times without success.
My solution was deleting ".project" files and the ".settings" directory in the several projects. Last step was reimporting as "Maven Projects" in eclipse.
I faced the issue too where my WebDriver and chrome driver was not being recognized even after adding the selenium dependencies. Followed below steps seeing the above comments.
And the issue got resolved. Thanks for the help.
Create a Maven project.
Add Maven dependencies(selenium and testng minimum)
Go to CMD to where your project is.
Run command mvn eclipse:clean
Then run command mvn eclipse:eclipse
Go to eclipse and refresh your project to apply the dependencies and then the jars are added to your project.

Categories

Resources