Running mvn idea:idea to generate IntelliJ IDEA project files we stumble into a folder that must be avoided, let's say .avoidMe, which is located inside every folder as a placeholder.
folder1
|
+- .avoidMe
|
+- folder2
| |
| +- .avoidMe
|
+- folder3
| |
| +- .avoidMe
. . .
I've looked at idea:idea exclude options but none of them accepts wildcars (e.g. .avoidMe , "/.avoidMe/" or else ) so that I need to add every possible path to the exclude property ( e.g. folder1/.avoidMe,folder1/folder2/.avoidMe,folder1/folder3/.avoidMe )
The idea here is to use it to run IDEA inspections and publish the results into Sonar.
Is there any way to exclude file search using a wildcard or any other trick than exhaustive path search ?
are there any other ways to run IDEA inspections and publish them into Sonar ?
You should never use mvn idea:idea, it's obsolete and was not updated for years. It's also known to generate incorrect projects with the bugs that will be hard to trace later.
Instead, just import pom.xml in IDEA, project files will be generated by IDEA automatically.
You can then Exclude certain folders in Project Structure | Modules | Sources. Be aware that this configuration will be lost on the next reimport.
There is another configuration to exclude folders that is global and will be not lost on reimport: Settings | File Types | Ignore files and folders.
Related
Is there a way to control where the .iws and .ipr files get generated? For instance, I have a project that is setup like this:
masterProj
|
+- devScripts
+- subProj1
+- subProj2
+- subProjX
Where the devScripts folder contains all our common build related stuff plus some code to boot-strap our Java apps. Currently it generates Eclipse projects, but I'd like to add the ability to generate IntelliJ projects as well. When we create our Eclipse workspaces we do that at the masterProj level, then import the project folders, including devScripts, under that. But if I run the gradle command in the devScripts folder for IntelliJ it places the .iws and .ipr files under devScripts, but it really should be one folder up.
What I'd like to end up with is something like:
masterProj
masterProj.iws
masterProj.ipr
|
+- devScripts
devScritps.iml
+- subProj1
subProj1.iml
+- subProj2
subProj2.iml
+- subProjX
subProjX.iml
I have a multi-module Maven project (one level deep only). I like not to have to repeat the same things in all child projects, but how can I still do it (avoir repeating) when the parent project itself needs a different setting ?
The example I’m facing is when trying to produce a common folder for all artifacts and dependencies (but I can imagine other equivalent situations):
<properties>
<__.build.folder>../last_build</__.build.folder>
</properties>
Of course, this will lead to a situation where I have two last_build folder, one common to all child projects, one in the upper level folder.
How can I avoid that without having to duplicate the same setting in every child pom.xml ?
Can I use profiles ?
I don’t know, I’m new to Maven.
Thanks
Edit :
In this example, last_build is a subfolder of the folder containing the parent pom.xml. The child projects are all in other subfolders, from which last_build has to be addressed as "../last_build" - but not in the parent pom.xml !
|
*--rootFolder
| |
| *--last_build // aggregation folder
| |
| *--subProject1
| | |
| | *--pom.xml (../last_build)
| |
| *--subProject2
| | |
| | *--pom.xml (../last_build)
| |
| *--subProject3
| | |
| | *--pom.xml (../last_build)
| |
| *--pom.xml (last_build) // different here for the parent project
I don't think you're proceeding down a very useful path and I think that you may be confused about a few things.
First, at the highest level, your root or parent pom, there should be no project, no code, no resources, and no artifact, so there should also be no output or need for an output directory. All you should have at the highest level is the parent pom and subdirectories containing modules.
The next problem is that you think you need a common build folder. I am hard pushed to imagine a rational scenario where that would be necessary. The artifacts one typically builds in maven are self-contained jars/wars -- one per module, and these are cached in the local repo whenever you build through the install lifecycle. They can be used in situ from there.
I want to run Sonar Runner only on some selected files only. I'm using SonarRunner Ant.
My project directory structure is :
MyProject
|
|-----src
|-----java
|-----A
|-----B
| |---<files>.java
|
|-----C
| |---<files>.java
|
|-----hello.java
Now I want to run Sonar Runner only on hello.java file.
sonar.sources=../../../MyProject/src // takes the source directory
sonar.sources=../../../MyProject/src/java/A/hello.java didn't work
sonar.exclusions=**/**/*.java // excludes all java files
// now I want to include only hello.java file
// didn't find any parameter for inclusion, but tried the following
sonar.inclusions=hello.java // didn't work
sonar.inclusions=java/A/hello.java // didn't work
Referred this article for analysis parameters.
One solution which crossed my mind is : exclusion of all the files but the required ones.
But here the structure is just a small part. In real I have more than 250 java files, and want to generate report for, say, 10 files only. Then, by this approach, excluding 240+ files doesn't look a good idea.
Is there anyway to generate sonar report on selected files, other than the mentioned approach?
If you're looking for specific files, you might try the same syntax as is listed to explicitly exclude files (Narrowing the Focus - at the bottom)
#Absolute Path
To define an absolute path, start the pattern with "file:"
#Exclude all the *.cs files included in /path_to_my_project/myProject/src/generated and its subdirectories
sonar.exclusions=file:/path_to_my_project/myProject/src/generated/**/*.cs
#Exclude all the java classes contained in a src/generated/java directory and its subdirectories
sonar.exclusions=file:**/src/generated/java/**/*.java
Good evening, people.
I've already wasted the whole day trying to manage with maven.
I have the following project structure:
base-pom.xml
|-module1
| |-module1-resources
|-module2
| |-module2-resources
|-module3
| |module3-resources
|
|-general-resources
I'm looking for some way of getting the following output structure:
output-folder
|-libs-folder/3rdrarty-jars
|-config-folder/general-resources not-packed
|-module1.jar
|-module2.jar
|-module3.jar
|-module1-resources not-packed
|-module2-resources not-packed
|-module3-resources not-packed
Also a thing to mention: classpath of my project modules should be something like this:
Class-Path: /config-folder module2.jar module3.jar libs/3rdparty_1.jar libs/3rdparty_2.jar libs/3rdparty_3.jar
I don't know if maven allows to have such a complicated output structure - all samples, i've found having wasted a lot of time, show nothing even similar to my requirements.
I'm looking for a quick way, for any given multi-module project, to show a quick overview of the project hierarchy including only the modules in the project, excluding external dependencies.
eg for a project
project root
+- A
+- B
+- C
+- D
+- E
+- F
+- G
+- H
I would like to see a quick, single screen view for A-H (like it is depicted here) that gives me a fast digestible view to get an idea of a project structure. Ideally it would be command line output, not a platform specific solution (I note there is a tool for VisualStudio).
mvn dependency:tree is great but too verbose for this case, I suppose I could grep and cut the output apart but feels like there should be an easier way (ie another plugin).
You can filter the dependency tree: http://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
So, if your group ID was com.foo.bar, you could get the projects in that group ID with:
mvn dependency:tree -Dincludes=com.foo.bar
Assuming all of your project's modules are within that group, that would cover your use case.
You could try this module here: MavenStructurePlugin
I had the same problem as you did and found it quite useful.
The output is pretty much what you seem to want:
test
|
|__ a
|
|__ b
|
|
\__ c
|
|__ d
|
|__ e
|
|__ f