vscode-java: picj pom-k3d.xml instead of pom.xml - maven

Currently, I've two "pom.xml" files into my project:
pom-k3d.xml
pom.xml
pom-k3d.xml contains some additional plugins and dependencies.
vscode is getting by default pom.xml.
Is there any way to set vscode pick pom-k3d.xml file instead?
Is there any way to split a "pom.xml file into two modular ones?
Any ideas?

Related

how can I modify Implementation-Version in manifest file?

my project uses spring core-Implementation-Version: 5.0.10.RELEASE in all packages
I want to change it to 5.3.24 in all packages.
I searched "5.0.10.RELEASE" in project and it is written only in manifest file.
So I thought I need to change the Implementation-Version in MANIFEST.MF in spring-core-5.0.10.RELEASE.jar
How can I do that?

Checkstyle and Maven's Standard Directory Layout

I'm following Maven's Standard Directory Layout for my project.
Is there a preferred directory to put my checkstyle.xml file? I've seen it on at least 3 possible locations:
src/main/resources/checkstyle.xml
src/main/checkstyle/checkstyle.xml - Example: Joda-Time
src/checkstyle/checkstyle.xml - Example: Spring Boot
Since this is mostly a file for developers, the first option gives me doubts. Would it make sense to include checkstyle.xml into the JAR file?
Thanks,
Fede
Putting checkstyle.xml in src directory doesn't really make sense, as it is not part of source code.
The most common convention I've observed in my projects is putting it into config/checkstyle/checkstyle.xml. Thousands of projects use it (filename:checkstyle.xml path:config/checkstyle) and Gradle uses this location by default.

How to use Afterburner.fx with Gradle instaed of Maven 3, while leaving the original project structure of afterburner.fx

afterburner.fx for JavaFX 8 is a minimalistic (3 classes) JavaFX MVP framework based on Convention over Configuration and Dependency Injection created by Adam Bien.
afterburner.fx use Maven 3.
I would like to use it with Gradle.
How to use Afterburner.fx with Gradle instaed of Maven 3, while leaving the original project structure of afterburner.fx ?
In the build.gradle File add dependencies
dependencies {
compile group: 'com.airhacks', name:'afterburner.fx', version: afterburnerfxVersion
}
In the build.gradle File add the additional Resources (.fxml , .css , .properties)
sourceSets.main.resources.srcDirs("src/main/java").includes.addAll(["**/*.fxml", "**/*.css", "**/*.properties"])
and (re-)add all the standard Resources (in the resources folder)
sourceSets.main.resources.srcDirs("src/main/resources").includes.addAll(["**/*.*"])
Update for Gradle Version 6.8.1 : if you run gradlew with --warning-mode all there is a deprecated Message:
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0.
Solution
add this line:
// from https://docs.gradle.org/6.8.1/userguide/upgrading_version_5.html#implicit_duplicate_strategy_for_copy_or_archive_tasks_has_been_deprecated
// and https://docs.gradle.org/current/userguide/java_plugin.html
// Java Plugin Task processResources(type: Copy)
processResources.duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
Thanks, this helped me a lot. I added the short form of it to dependencies:
compile 'com.airhacks:afterburner.fx:1.6.0'
Additionally I added a second line to include the files from the resources folder and not only from /java. I also added **/*.png to include png files because new Image("filename.png") wasn't working anymore.
sourceSets.main.resources.srcDirs("src/main/java").includes.addAll(["**/*.fxml", "**/*.css", "**/*.properties", "**/*.png"])
sourceSets.main.resources.srcDirs("src/main/resources").includes.addAll(["**/*.fxml", "**/*.css", "**/*.properties", "**/*.png"])
I don't know why the above two lines broke the default behavior - seems like I have to add every new file type to the above lines. :/ If anyone has a better solution please tell me.

SonarQube Exclude a directory

I am trying to exclude a directory from being analyzed by Sonar. I have the following properties defined in my sonar-project.properties file:
sonar.sources=src/java
sonar.exclusions=src/java/test/****/*.java
The directory structure I have is:
src/java/dig
src/java/test/dig
When I run the sonar-runner I get the following info:
INFO - Excluded sources:
INFO - src/java/test/**/*.java
INFO - Excluded tests:
INFO - **/package-info.java
But when I check the result of the analysis all the packages inside the test directory are still there.
I just need to tell Sonar to not analyze the test directory and any packages inside it.
Try something like this:
sonar.exclusions=src/java/test/**
I'm able to exclude multiple directories using the below config (comma separated folder paths):
sonar.exclusions=system/**, test/**, application/third_party/**, application/logs/**
And while running the sonar runner I got the following in the log:
Excluded sources:
system/**
test/**
application/third_party/**
application/logs/**
This will work for your case:
sonar.exclusions=**/src/java/dig/ ** , **/src/java/test/dig/ **
Another configuration option is adding a maven properties sonar.exclusions. Below is a sample pom file with exclusions of static jquery directory and static pdf viewer directory.
<project >
<modelVersion>4.0.0</modelVersion>
<artifactId>my Artifact</artifactId>
<!-- Enviroment variables can be referenced as such: ${env.PATH} -->
<packaging>war</packaging>
<url>http://maven.apache.org</url>
<properties>
<junit.version>4.9</junit.version>
<mockito.version>1.9.5</mockito.version>
<jackson.version>1.9.7</jackson.version>
<powermock.version>1.5</powermock.version>
<!--Exclude the files Here-->
<sonar.exclusions>src/main/webapp/static/jquery_ui/*,src/main/webapp/static/pdf-viewer/*,src/main/webapp/static/pdf-viewer/**,src/main/webapp/static/pdf-viewer/**/*</sonar.exclusions>
</properties>
If we want to skip the entire folder following can be used:
sonar.exclusions=folderName/**/*
And if we have only one particular file just give the complete path.
All the folder which needs to be exclude and be appended here.
Easiest way is to go to the server URL after starting the server(localhost:8080) then login as admin,Go to settings>Exclusions> Source File Exclusions- Add your packages here.
Restart the server.
If you're an Azure DevOps user looking for both where and how to exclude files and folders, here ya go:
Edit your pipeline
Make sure you have the "Prepare analysis on SonarQube" task added. You'll need to look elsewhere if you need help configuring this. Suggestion: Use the UI pipeline editor vs the yaml editor if you are missing the manage link. At present, there is no way to convert to UI from yaml. Just recreate the pipeline. If using git, you can delete the yaml from the root of your repo.
Under the 'Advanced' section of the "Prepare analysis on SonarQube" task, you can add exclusions. See advice given by others for specific exclusion formats.
Example:
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
sonar.exclusions=MyProjectName/MyWebContentFolder/**
Note: If you're not sure on the path, you can go into sonarqube, view your project, look at all or new 'Code Smells' and the path you need is listed above each grouping of issues. You can grab the full path to a file or use wilds like these examples:
MyProjectName/MyCodeFile.cs
MyProjectName/**
If you don't have the 'Run Code Analysis' task added, do that and place it somewhere after the 'Build solution **/*.sln' task.
Save and Queue and then check out your sonarqube server to see if the exclusions worked.
what version of sonar are you using?
There is one option called "sonar.skippedModules=yourmodulename".
This will skip the whole module. So be aware of it.
You can do the same with build.gradle
sonarqube {
properties {
property "sonar.exclusions", "**/src/java/test/**/*.java"
}
}
And if you want to exclude more files/directories then:
sonarqube {
properties {
property "sonar.exclusions", "**/src/java/test/**/*.java, **/src/java/main/**/*.java"
}
}
Add comma separated folder paths sonar.exclusions=**/abc/**,**/def/**
This worked in an angular project
I typed case sensitive and used "" and it worked. Analyze time decreased to 3 minutes from 10.
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
sonar.exclusions=**\Scripts\**\*,**\Content\**\*
Just to mention that once you excluded the files from Sonar, do the same for Jacoco plugin:
<configuration>
<excludes>
<exclude>com/acme/model/persistence/entity/TransactionEntity*</exclude>
<exclude>com/acme/model/persistence/ModelConstants.class</exclude>
</excludes>
</configuration>
add this line to your sonar-project.properties file
ex: sonar.exclusions=src/*.java
be careful if you want to exclude a folder and inside the folder there is a file you must first exclude the files or add the files one by one
for example imagine there is a folder like below:
src/app.java
src/controllers/home.java
src/services/test.java
you have to do this:
sonar.exclusions=src/app.java,src/controllers/*.java,src/services/*.java
It worked for me
You can skip library like this
project(":libABC") {
apply plugin: 'org.sonarqube'
sonarqube {
skipProject = true
}
}
This worked for me:
sonar.exclusions=src/**/wwwroot/**/*.js,src/**/wwwroot/**/*.css
It excludes any .js and .css files under any of the sub directories of a folder "wwwroot" appearing as one of the sub directories of the "src" folder (project root).

export all defined maven project properties to file?

I have a maven 3 project. In the POM, I define numerous <properties> - some under <project>, others under specific <profile>. is the a way in maven to export all declared properties to a .properties file?
My current way of doing so is to:
create env.properties file in src/main/resources
for each property 'myProp' add this line to env.properties: myProp=${myProp}
enable resource filtering during builds
Seems like there ought to be a way to eliminate step 2 above...
thanks,
-nikita
Use properties-maven-plugin and its write-project-properties goal.
If I understand your requirements correctly, you can do this using the antrun-plugin coupled with Ant's echoproperties task. An example of this configuration is in the StOf question here.

Resources