Is there anyway to specify project-specific coding style that will get loaded in IntelliJ from a pom.xml? - maven

If I have a Maven project, and someone is going to load the project by opening the pom.xml file in IntelliJ, is there anything I can put in the file or elsewhere in the project that will load project-specific coding styles into the IDE?

Not by importing from a pom only. What you can do is add some IntelliJ files to the source code management tool. Idea saves its project specific code styles into /.idea/codeStyleSettings.xml - it may just picks it up after you imported the project via maven/pom.xml. I think it does not hurt to add a few other files too. Here is my .gitignore for intellij 13.1.5:
target/
# intellij settings files:
.idea/artifacts/
.idea/dictionaries/
.idea/copyright/
.idea/inspectionProfiles
.idea/libraries/
.idea/scopes/
.idea/compiler.xml
.idea/uiDesigner.xml
.idea/vcs.xml
.idea/rebel_project.xml
.idea/dataSources.ids
.idea/workspace.xml
Everything else is under version control. (some developers dont like that - I know - just wanted to mention it)

Related

How is this timestamp file generated from maven build?

I was working on a maven project and this project is generating some weird file.
The file name are like:
[PROJECT]/target/classes.531226305.timestamp
[PROJECT]/target/classes.1241815416.timestamp
[PROJECT]/target/test-classes.-1983166104.timestamp
And the content of the file are only a .(dot) inside it. Anyone has any idea of how this is generated? Thanks!
Does the project use the scala-maven-plugin? The scala-maven-plugin adds ".<hashcode>.timestamp" to files in the target directory. It's used for the incremental compile feature that is available for that plugin.

How to save a module from one computer and import into into another computer in IntelliJ with Maven

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

Maven - Wrong folder structure

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.

How to enable jsp-tags autocompletion in NetBeans within NetBeans Maven projects?

Using NetBeans 7.1.2.
When editing pages with NetBeans as per the procedure explained below, the IDE offers only autocompletion for <jsp:...> tags:
This is how I have created the NetBeans project and the jsp (though it isn't archetype specific, nor the issue has anything to do with opencms): I have created a maven project with the OpenCms-Module archetype
mvn archetype:generate -DarchetypeCatalog=http://bp-cms-commons.sourceforge.net/m2repo
The archetype creates a maven project with jar packaging.
After that, I have added a jsp under src/main/opencms/modules/blahblah/templates.
And then I have added the taglibs.standard dependency to the project, to try to provide NetBeans with the corresponding tlds.
After several hours trying to get this working, I found this reported and closed bug that hinted me into the right direction:
Added src/main/webapp directory Edit 1: There is autocompletion only for jstl tags if the files are inside src/main/webapp. Workaround in linux (not sure if windows links will work): Create a symlink:
ln -s opencms/ src/main/webapp from the project root folder
Change maven project packaging to war (Project properties -> General -> Packaging)
(Notice that neither the #taglib directive nor the taglibs.standard dependency are necessary.)
If the Web Pages entry does not appear under your project (in the projects view), you may need to restart NetBeans. Now you'll have full autocompletion (only) under src/main/webapp! :-)
Edit 2
Unfortunately, if under version control, NetBeans sees the symlink as a new directory, and all files under it, as new files :-( This is very inconvenient, because to access the IDE integrated version control functionality, you still need to open the original resource.

How to configure Maven project to not expect resources directory in Eclipse

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...

Resources