Unable to execlude packages from code analysis - jenkins

I am using Spring Boot JPA example and in the pom.xml we've configured to completely exclude the packages to to be removed during static code analysis.
<properties>
<java.version>1.8</java.version>
<sonar.exclusions>
**/enums/**/*,**/entity/**/*,**/constant/**/*,**/dto/**/*,**/repository/**/*
</sonar.exclusions>
<sonar.test.exclusions>**/test/**</sonar.test.exclusions>
</properties>
But we've seen that these packages are not getting excluded. Any pointers why ?

Follow this procedure to exclude these packages:
Click on your project name in SonarQube -> Administration -> General Settings -> Analysis Scope -> Source File Exclusions (You can put the file pattern in the text box)
This will skip the files which matches the given pattern.

Related

sonar.coverage.exclusions and sonar.exclusions does not exclude the files from

I already went through : Configure Sonar to exclude files from Maven pom.xml and still SonarLint is unable to execlude those all files.
Any help is much appreciated
<properties>
<java.version>1.8</java.version>
<sonar.coverage.exclusions>
**/dto/**/*, **/entity/**/*,
**/exception/**/*, **/repository/**/*,
**/enums/**/*,
**/assembler/**/*,
**/src/main/resources/sql/**/*,
**/controller/**/*,
**/utils/**/*,
**/security/**/*,
**/servlet/**/*,
**/MainApplication.java
</sonar.coverage.exclusions>
<sonar.exclusions>
**/entity/**/*,
**/constant/**/*,
**/repository/**/*,
**/src/main/resources/sql/**/*,
**/enums/**/*
</sonar.exclusions>
</properties>
Follow this procedure to exclude the files: Click on your project name in SonarQube -> Administration -> General Settings -> Analysis Scope -> Coverage Exclusions OR Source File Exclusions (You can put the file pattern in the text box)
This will skip the files which matches the given pattern.

Create and Publish nuget packages from TFS build process?

I want to create nuget packages (and deploy them to my private nuget repository) after my assemblies are compiled.
I tried setting everything up by using NuGetter, but that project is kind of inactive and only allows you to build one package/project while I need one package/assembly.
Now I'm kind of stuck. I'm currently looking at their source, hoping to make it more useable for me.
What I'm asking here, in parallel, is: Does anyone have a finished solution for publishing/creating nuget packages from TFS 2012 and/or TFS2010 for multi-package solutions?
I tried setting everything up by using NuGetter, but that project is kind of inactive and only allows you to build one package/project while I need one package/assembly.
NuGetter does support multiple packages, i only use the multiple package method now as you can use it for single or multiple packages.
by using a packages xml file you can specify the multiple packages
<?xml version="1.0"?>
<NuGetterPackages>
<NuGetterPackage name="Package1">
<NuSpecFilePath>Package1.nuspec</NuSpecFilePath>
<BasePath>NuGetPrePackage_Package1</BasePath>
<InvokePowerShell>True</InvokePowerShell>
<PowerShellScriptPath>PrePackage_Package1.ps1</PowerShellScriptPath>
<InvokePush>True</InvokePush>
<OutputDirectory>NuGetPackage</OutputDirectory>
<PushDestination>\\MYFeedLoc\NugetFeed</PushDestination>
<Version>1.0.J.B</Version>
</NuGetterPackage>
<NuGetterPackage name="Package2">
<NuSpecFilePath>Package2.nuspec</NuSpecFilePath>
<BasePath>NuGetPrePackage_Package2</BasePath>
<InvokePowerShell>True</InvokePowerShell>
<PowerShellScriptPath>PrePackage_Package2.ps1</PowerShellScriptPath>
<InvokePush>True</InvokePush>
<OutputDirectory>NuGetPackage</OutputDirectory>
<PushDestination>\\MYFeedLoc\NugetFeed</PushDestination>
<Version>1.0.J.B</Version>
</NuGetterPackage>
</NuGetterPackages>
under source control i have the packages.xml file, and then per Nuget Package a powershell file and a nuspec file.
Nuspec File looks like this
<?xml version="1.0"?>
<package >
<metadata>
<id>Package1</id>
<version>$version$</version>
<title>Package1</title>
<authors>Package1 Author</authors>
<owners>Package1 Owner</owners>
<iconUrl>http://Iconserver/nextlogo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description of Contents</description>
<releaseNotes>First release of the package.</releaseNotes>
<copyright>Copyright 2014</copyright>
<tags>Space Seperated Tags</tags>
<dependencies>
<dependency id="AnyLatestDependencyIMayHAve" version=""/>
<dependency id="AFixedDependencyIMayHAve" version="[1.0.0]"/>
</dependencies>
</metadata>
</package>
And then a Powershell file that just creates the folder structure within the BasePathDeclaration in the Packages.xml, this is the same file as shown on the NuGetter site
I have added a full explanation at my blog

Selecting optional dependencies of OSGi-bundles with Ivy

I use Ivy to resolve OSGi bundles, like org.eclipse.jdt:
<dependencies>
<dependency org="bundle" name="org.eclipse.jdt" rev="x.y.z"/>
</dependencies>
It works fine and gives me all mandatory dependencies.
My question is, how can I select some (not all) optional dependencies of transitive bundles?
I can:
Select optional dependencies of org.eclipse.jdt by activating use_xxx configuration
Select all optional dependencies using transitive-optional configuration
What I actually need is a possibility to globally activate a configuration use_yyy. Globally means (applying to all transitive dependencies):
If a module doesn't have this configuration, do nothing
If a module does have this configuration, activate it

Maven transitive dependencies

I have 3 maven projects: first - "A" with packaging jar, second - "B" packaging jar, third - "C" packaging jar. "C" depends on "B" as compile time dependency, "B" depends on "A" also as compile time dependency. Project "C" also uses classes from "A". So I have transitive dependency C -> B -> A. But when I try to build these projects maven failed with compilation error while compiling project C: it can't find classes from project "A" that is used in "C".
I thought that maven resolves transitive dependency. Why I get such an error?
Maven resolves transitive dependencies, but will not (usually) automatically build them for you. You can get maven to do what you want by supplying the --also-make/-am flag along with the project list:
mvn -am -pl C clean install
This assumes that A, B, C are all modules of a shared parent, and you would be running the command above in the parent's directory.
The failure of transitive dependency in Maven occurs due to many reason. You need to enable debugging option for that.
I faced similar issue. I am using eclipse. To enable debug option for maven in eclipse: Windows->Preference->Maven->Tick mark Debug Output
Error in my project was:
[WARNING] The POM for mil-pop2:java-json:jar:1.0 is invalid, transitive dependencies (if any) will not be available: 4 problems were encountered while building the effective model for mil-pop2:java-json:1.0
[ERROR] 'dependencies.dependency.systemPath' for java-json.jar:java-json.jar:jar must specify an absolute path but is ${project.basedir}/src/main/resources/lib/java-json.jar #
The reason for failure in transitive dependency is the project in which we are dependent inherits the jar from custom path rather than local repository. Remove the custom path if you have provided.
Before :
<dependency>
<groupId>java-json</groupId>
<artifactId>java-json.jar</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/java-json.jar</systemPath>
</dependency>
After:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
This solved my error.

Non-resolvable parent POM using Maven 3.0.3 and relativePath notation

After migrating to Mavent 3.0.3 Parent poms in several Projects cannot be resolved anymore.
The Projects are structured in a default manner, so I set
parent.relativePath to "../pom.xml"
superpom (located in repository)
|-rootpom (located locally: no error)
|-|-parentpom (located locally: error resolving parent)
|-|-|-module1 (located locally: error resolving parent)
|-|-|-module2 (located locally: error resolving parent)
|-|-|-module3 (located locally: error resolving parent)
|-|-|-module4 (located locally: error resolving parent)
The Error...
Non-resolvable parent POM for myGroup:myArtifactId:1.0: Failure to
find myGroup:myParentArtifactId:1.0 in
http://myRepo.net/archiva/repository/maven2 was cached in the local
repository, resollution will not be reattempted until the update
interval of maven2 has elapsed or updates are forced and
'parent.relativePath' points at wrong local POM #
myGroup:myParentArtifactId:1.0, C:\myProjectDir\parent\pom.xml, line
x, column y -> [Help 2]
... seems to indicate that the pom was searched for in the repository, so I wonder why the pom was not found locally before looked elsewhere.
I have read that maven3 might get confused when several repositories are defined in the settings.xml, but that was always when searching for a pom inside repositories and not locally.
update
Up until now we did execute the maven build on the parent-project level (parentpom) - a fact which I did not know was important, since maven2 completed successfully until now.
When using maven3 this seems to be of importance.
When executing maven3 on the root-project level (rootpom) the build finishes successfully.
So my immediate problem is solved.
Since I don't necessarily want to answer my own question maybe
someone can explain why maven3 behaves this way now or why the old
approach was wrong.
Make sure you Double-Check that the version you refer to in the child-pom is the same as that in the parent-pom. For me, I'd bumped version in the parent and had it as 3.1.0.0-RELEASE, but in the child-pom, I was still referring to the previous version via relativePath, and had it defined as 2.0.0.0-SNAPSHOT. It did not make any difference if I included just the parent directory, or had the "pom.xml" appended to the directory:
<parent>
<artifactId>eric-project-parent</artifactId>
<groupId>com.eric.common</groupId>
<!-- Should be 3.1.0.0-RELEASE -->
<version>2.0.0.0-SNAPSHOT</version>
<relativePath>
../../EricParentAsset/projects/eric-project-parent</relativePath>
</parent>
Here is answer to your question.
By default maven looks in ../pom.xml for relativePath. Use empty <relativePath/> tag instead.
'parent.relativePath' points at wrong local POM #
myGroup:myParentArtifactId:1.0, C:\myProjectDir\parent\pom.xml
This indicates that maven did search locally for the parent pom, but found that it was not the correct pom.
Does pom.xml of parentpom correctly define the parent pom as the pom.xml of rootpom?
Does rootpom folder contain pom.xml as well as the paretpom folder?
I had the same problem. My project layout looked like
\---super
\---thirdparty
+---mod1-root
| +---mod1-linux32
| \---mod1-win32
\---mod2-root
+---mod2-linux32
\---mod2-win32
In my case, I had a mistake in my pom.xmls at the modX-root-level. I had copied the mod1-root tree and named it mod2-root. I incorrectly thought I had updated all the pom.xmls appropriately; but in fact, mod2-root/pom.xml had the same group and artifact ids as mod1-root/pom.xml. After correcting mod2-root's pom.xml to have mod2-root specific maven coordinates my issue was resolved.
You need to check your relative path, based on depth of your modules from parent if module is just below parent then in module put relative path as:
../pom.xml
if its 2 level down then
../../pom.xml
Please check in logs if you have http.HttpWagon$__sisu1:Cannot find 'basicAuthScope' this error or warning also, if so you need to use maven 3.2.5 version, which will resolve error.
<parent>
<groupId>com.test.vaquar.khan</groupId>
<artifactId>vk-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../projectname/pom.xml</relativePath>
</parent>
Add following line in parent
<relativePath>../projectname/pom.xml</relativePath>
You need relative path if you are building from local parent pom not available in nexsus, add pom in nexus then no need this path
For me, it works when I double checked the parent´s "group ID" and "artifact ID" that in my case were the wrong ones and that was the problem.

Resources