I have checked in one of my projects to GIT repo. When i cloned it from GIT, imported the project to eclipse and converted the project to Maven Project, the folder structure of maven seems to be a bit different
This should have been src/main/java, src/test/java, src/test/respurces folder structures and com.vod... as package.
I have tried maven>update project, project>clean, maven>clean, eclipse::clean, eclipse::eclipse. But this project structure does not seem to go off.
Any possible solutions for this please?
After importing the project as eclipse general project, below is the structure.
This is a typical problem due to the lack of Eclipse metadata files in the GIT repository.
How to solve it:
Open the project's contextual menu > Java Build Path > Configure Build Path > Source. Drop off folder src and set as folder sources just these:
src\main\java
src\main\resources
src\test\java
src\test\resources
This will save some metadata to the .classpath file.
Also, you should ensure that this was set as a Maven project: Open the project's contextual menu > Configure. If there is the Convert to Maven command, execute it (if not, it is already a Maven project). This might save some metadata to the .project file.
Then, be sure to check in the Eclipse metadata files (.classpath, .project and .settings folder) to GIT. And, in order for this project can be safely shared to other developers, be sure not to enter absolute paths in the java build path, nor other system-dependant constraints.
Related
Previously we made a Gradle project in Intellij and all the gradle files were there under the project. However, we have now moved the files in this project to a sub folder, but the Gradle files aren't being recognised. The picture below is the new folder set up where our code from the original project is now in the server folder (where the Gradle files are). When I mark the src folder (under server) as the Sources Root, that is when the dependencies from Gradle aren't recognised.
I figured out that the correct way to go is actually to separate out the client/server folder into two separate modules.
I have a Maven module in IntelliJ which works fine from one computer. I have saved the ".iml" file together with the project in Git. When I check it out on another computer,
"New Project"
then "File" -> "New Module from Existing Sources" -> Select the ".iml" file, the structure is all there, but no Maven dependencies are resolved.
How do I get IntelliJ to download and import the Maven dependencies?
Things I have tried:
"Re-build Project"
Right-click the module and "Re-build module"
"File" -> "Invalidate Caches / Restart" (both invalidate and restart)
"Re-import All Maven Projects", this simply deleted the two Maven modules from the project. I then had to re-create the modules as above, once they were there again I had the same problem.
On the comand-line "mvn" is able to import the project and resolve all dependencies just fine.
Additional information:
The ".iml" file, when I look at it in a text editor, does not have any absolute paths in it.
Here is a picture of the module settings window:
If your goal is to just import the project on another PC, don't rely on the iml files. Some even consider it bad practice to commit IDE specific files in maven projects, as not everyone on a project might use the same version or even a different IDE. If you take a look at popular .gitignore files (e.g. this one), you'll most often find that any IDE specific files get excluded.
Consider importing the projects pom.xml:
Import Project -> from external model -> Maven
EDIT
JetBrains recommends to NOT include the iml file with Maven or Gradle projects, see here
I have imported a existent maven project (swagger for jersey jax-rs) into eclipse.
I get a bunch of errors:
It always has to do with the jackson-databind.jar
Example error:
Archive for required library: '.../.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.5/jackson-databind-2.1.5.jar' in project 'swagger-core_2.9.1' cannot be read or is not a valid ZIP file
I cannot find the .m2 folder? I am new to the maven stuff,
do i have to install something extra before i import a maven project into eclipse?
Thx
I cannot find the .m2 folder?
By default the .m2 directory is located at the home directory.
For *Unix operating systems, it will be something like /home/<user_who_fires_maven_commands>/.m2/...
For Windows machines , the m2 will be located at C:\Users\<user>\.m2\...
As for the exception you are getting
Archive for required library: '.../.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.1.5/jackson-databind-2.1.5.jar' in project 'swagger-core_2.9.1' cannot be read or is not a valid ZIP file
It is most probable that the archive file has gotten curropted ( maybe a download issue or might be possible that its sha1 doesn't match with the one that is on the central repo ). So you can try by simply deleting this jar file and then run mvn install and it will re-attempt to download the file again.
Another thing I would like to point out is that since this is a new eclipse installation, I would suggest that you re-index your local m2 folder so that this new eclipse knows about the files and folders inside the original m2 folder. To re-index, goto Window -> preferences --> Maven --> User settings --> there will be a text field stating the path of the .m2 ( make sure its correct ) and then press re-index
I am having an eclipse project created on Ubuntu, in which all the JARs that I am using, are located in a folder /home/xyz/AllJARs. Here the /home is the system home folder. The project as well as the AllJARs folder is git version controlled on a central git server.
So, all the paths to these JARs in the project's build path are /home/xyz/AllJARs. When I'm cloning the project repo and the AllJARs repo on a Windows machine, I'm shown errors related to build path since it can't find the path /home/xyz/AllJARs.
How can I manage this situation where I can have external JAR files in build paths which can work on Ubuntu as well as on a Windows machine? Thanks in advance.
You have two easy options:
use relative paths: for example, put the JAR folder in the folder above your project, then you can set the JARs' paths to ../AllJARs/
put JARs into project: you can also just put the JARs into the project folder; if you've set them up as "External JARs" in project settings, you'll have to remove them from that list, and re-add them with "Add JARs". Eclipse will then look for them locally in the project folder. If you don't want to commit the JARs to the git repo (size and/or permission being a problem), you can just copy them into the Project folder after cloning. While they're not there, you'll be shown a warning, but once Eclipse can find them, everything's fine.
I do not have any resources for my Maven project so I want to stop Maven expecting these directories and so remove these Java Build Path Problems in Eclipse,
Project 'XXX' is missing required source folder: 't-services/src/test/resources'
Project 'XXX' is missing required source folder: 'tlib/src/main/resources'
How do I configure pom.xml to achieve this?
A quite old thread, but I just faced the similar errors in Eclipse, after having deleted the src/main/java + resources and src/test/java + resources from Eclipse directly, as my project is only containing a pom file (packaging=pom).
To properly remove the errors, I just right-clicked on the project > Properties > Java Build Path > 'Source' tab, and there I removed the obsoletes entries. In the end, it modified the .classpath file of the project.
Janek, I saw similar with m2e <= 1.0 but it seems to be fixed with m2e 1.1.
I was able to clear up a similar problem. I removed the projects from Eclipse; deleted all of the .project, .classpath, and .settings files and directories from the file system; imported the project into Eclipse again. The problem went away.
you have to simply remove those folders from your project after that there shouldn't be any problem...But the message gives me the impression that those folders have been configured wrong...