Sonar properties file - ignoring doesn't work - eclipse-plugin

Issue: I am trying to set the sonar-project.properties to ignore a module or a package and it doesn't work.
I am totally new to Sonar and I'm using the eclipse plugin on a java maven project and I'm trying to ignore stuff (e.g. a package or a module) but the sonar-project.properties file doesn't seem to have any effect.
I have only one properties file in the root of my project. And there are 2 modules (one for java and one for webapp)
sonar.projectKey=projectname
sonar.projectName=projectname
sonar.projectVersion=1.0
sonar.modules=javamodule,webapp
sonar.sources=src/main/
sonar.tests=src/test/java
sonar.java.binaries=target/classes
sonar.java.libraries=../*/target/**/*.jar
If I try to exclude something like
sonar.exclusions=com/package/files/**/*
or
webapp.sonar.exclusions=resources/**/*
then I do analyze on the module and nothing was ignored. I also tried adding individual properties files inside the modules..
Also, I would like to ignore the whole webapp module. Should I just not declare it, or is there some other way?
Edit:
For example's sake, this is my package structure
javamodule
- src/main/java
- com/package/files
- src/main/resources
- src/test/java
- src/test/resources
webapp
- src/main/resources
- src/main/webapp

The SonarQube Eclipse plugin only takes into account exclusions set through the web interface. It doesn't take into account exclusions set in configuration files such as sonar-project.properties files.

Related

How to open pom.xml project using IDEA

I am trying to learn about annotation processing by looking at this sample.
I've cloned it to my local machine and used IDEA to open it.
However IDEA tells me:
Project SDK not set up.
After setting up Java SDK, the project is not opening correctly. So how can I open this project?
The project structure :
annotationprocessing10
|
|------factory
|-----annotation
|------pom.xml
|-----processor
|------pom.xml
|-----pom.xml
|-------factory-sample
I tried opening annotationprocessing10 (root) directly and also tried factory directly but neither worked. Here is a screenshot of the directory structure:
The given repo is not a maven module (no POM.xml in the base directory), the maven modules are the projects inside.
Make sure you import the modules inside the root directory in IDEA to identify it as a maven project.

IntelliJ, JRebel, Maven and a JEE 6 application

My setup is
IDE: IntelliJ
Application: JEE6 with an EAR and a WAR module
Build: Maven
Hot-Code-Replacement: JRebel
App-Server: Glassfish 3.1
I configured the application in IntelliJ in a way that the ear gets deployed. The ear "target" folder looks like this
target/classes/
target/appEar/appWeb-version-Snapshot.war/
target/appEar/lib/
target/appEar/META-INF
In the default configuration JRebel listens for changes in the classes/ folder.
When I change something in the web module, and build this, the classes are only updated in appWeb/target/classes/ but not in appEar/target/appEar/appWeb-version-Snapshot.war/.
If I want to update those classes I have to select "Build Artifacts" in IntelliJ after building the project.
To sum up, I have to do these steps for a hot code replacement:
(once) Configure JRebel correctly.
Make project
Build Artifacts
This whole procedure appears to be too complicated to me. Does anyone have a clue how to setup IntelliJ/Maven/Glassfish/JEE/JRebel correctly? I have not found an example containing all my tools. I'd like to have only one action for the code replacement, not two.
There's "build on make" checkbox in your project artifact settings, that will always recreate your artifact on compiling, if that's what you are looking for. However JRebel should remap where your application is reading class files and resources based on rebel.xml, so you probably should just rewrite rebel.xml to look for classes where they are compiled to, not where they end up after building the artifact.
Why do you need to Build Artifacts every time?
Your war should contain the rebel.xml that maps to the classes in /target/classes folder.
When you make changes to said classes, your server then knows to load the changes from those classes.
So you only need to build your project in order to see the changes assuming your rebel.xml classpath points to /target/classes.

What is a working directory in Intellij IDEA

I created a Maven project and imported it in Intellij IDEA.
In a run configuration, there is a field "working directory", which points to the root of Maven project.
If I change this folder, it doesn't seem to affect anything. So what is it?
This is the directory that is set as the Java user.dir system property. If you have any code that creates relative files or directories, it will be relative to this directory. So for a well designed application (i.e. resolves resources from the classpath and is configurable for output directories) this will not be a factor. There is also some importance to this value in maven projects, especially multi-module maven projects. This directory specifies the directory IDEA will read the POM from.
If you are unflamilar with what the Java user.dir is, there is some discussion available here and in the class level Javadoc for the File class.
In addition to answer given by #Javaru if you want to update or view your working directory in IntelliJ IDEA go to:
Run | Edit Configurations | Configuration Tab | Working Directory
From the IntellJ help Run/Debug Configuration: Maven
Working directory Specify the path to the Maven project file pom.xml.

logback.xml and running application from JetBrains IDEA IDE

When I develop application in IDEA, where should I place logback.xml for it to have an effect on the application?
It seems when you run/debug IDEA doesn't make any jars and doesn't invoke Maven to build something. Does it execute main() directly from compiled *.class file? If so, where can I put logback.xml so that it would have effect?
logback.xml should be available in the root directory of your CLASSPATH. When you run your application, the full CLASSPATH is printed at the very beginning. When I put logback.xml in /src/main/resources (Maven project) it works without any problem. Also putting it in /src/test/resources with logback-test.xml name has presence.
Simply run:
getClass().getClassLoader().getResource("/logback.xml");
And see whether it returns something or null.
If you are not working with Maven project, open Project structure (Ctrl + Alt + Shift + S) and add in Modules section select folder containing logback.xml and mark it as Sources (blue icon).
For me: I simply needed to re-build the project (not just re-run or re-compile the project). Changing the src\main\resources\logback.xml did not affect logback because the class loader is picking up the logback.xml that is in the target/ folder, not the /src folder. This makes sense since target is the run environment. Therefore, a build is required to transfer the new xml file over to target.

intelliJ 9 cannot find class I specify in web.xml

I am trying to get logdigger to work in my java app that uses google app engine. I have tried putting my jar files in the src/ directory, lib/ directory, and no matter what I do, it can't find the class. The only thing that it finds is the com.google.appengine stuff. I have tried messing with my dependencies and it's not working. Has anyone done this before and gotten it to work? I am not sure how to modify the classpath through intelliJ (however in the project settings I have the jars linked as a dependency under the modules section).
You probably need to look at the artifacts for your project. IntelliJ separates runtime assembly of WARs into the artifacts section. Look and see that your WAR file is assembled properly. I'm guessing that you don't put the contents of the /lib directory into the WEB-INF/lib of your WAR. The compiled output ought to go into WEB-INF/classes. All other output belongs in the root of the deployment.