I'm getting SpotBugs warning with code 'EI_EXPOSE_REP2' for class field
private final LocalDate localDate
I'm trying to exclude this check for java.util.LocalDate class for whole app.
I tried to use annotation #SuppressFBWarnings("EI_EXPOSE_REP2") and it works. But for me this is not good idea of adding this annotation into every place where LocalDate is used. Instead of that I would prefer to add this rule to spotbugs-exclude.xml. And I did so but it's not working (still getting SpotBugs warning). My spotbugs-exclude.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="java.time.LocalDate" />
<Bug code="EI_EXPOSE_REP2" />
</Match>
</FindBugsFilter>
pom.xml
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs.mavenplugin.version}</version>
<executions>
<execution>
<id>spotbugs-verify</id>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
So my question: how could I exclude SpotBugs checking for specific class in whole app?
Additional question: could we mix up spotbugs-exclude.xml and annotations #SuppressFBWarnings inside the same app? Is SpotBugs able to recognize both configurations?
I have done more investigations and found similar topic here: https://github.com/spotbugs/spotbugs/issues/1601
So looks like for 4.3.0 version SpotBugs plugin has buggy behavior with checking immutable classes and provide warning EI_EXPOSE_REP and EI_EXPOSE_REP2.
So my decision: migrate from 4.3.0 to 4.2.3 - currently all works.
Related
I am trying to workout a generated server side Spring MVC code for a OpenApi 3.0.2 specification.
This is how one of the `paths' look like :-
paths:
/api/v1/int/integrations/{some-path-variable}/some-action:
get:
summary: Summary
description: How to change the generated Api/Controller class name?
operationId: methodName
tags:
- inventory
parameters:
- name: Authorization
other details....
The server side code get generated using the Maven plugin which is configured as :-
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.1.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/open-api/myapi.yaml</inputSpec>
<generatorName>spring</generatorName>
<library>spring-boot</library>
<output>${project.build.directory}/generated-openapi/spring</output>
<generateApis>true</generateApis>
<addCompileSourceRoot>true</addCompileSourceRoot>
<artifactVersion>${project.version}</artifactVersion>
<groupId>com.company.division</groupId>
<artifactId>myapi-api</artifactId>
<generateApiTests>true</generateApiTests>
<modelPackage>com.company.division.myapi.generated.model</modelPackage>
<apiPackage>com.company.division.myapi.generated.api</apiPackage>
<generateApiDocumentation>true</generateApiDocumentation>
<configOptions>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
<reactive>false</reactive>
<useBeanValidation>true</useBeanValidation>
<performBeanValidation>true</performBeanValidation>
<useOptional>false</useOptional>
<serviceInterface>true</serviceInterface>
<serviceImplementation>false</serviceImplementation>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
As seen in the plugin configuration, I am only interesed in generating the model classes and Spring Controller Interfaces / API interfaces.
Problem
For the mentioned OpenAPI spec, the generated MVC Controller inerfaces is named as ApiApi. I am guessing that is derived from the path's begining part. I could get rid of the /api/v1/int part but that will generate interface named IntegrationsApi but I wan't it to be named say InventoryApi.
What option we have to control the generated controller interface?
'useTags' creating interface and controller classnames
Setting useTags configOption inside plugin configuration fixed my problem:
<configuration>
<configOptions>
<useTags>true</useTags>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<interfaceOnly>true</interfaceOnly>
<reactive>false</reactive>
<useBeanValidation>true</useBeanValidation>
<performBeanValidation>true</performBeanValidation>
<useOptional>false</useOptional>
<serviceInterface>true</serviceInterface>
<serviceImplementation>false</serviceImplementation>
</configOptions>
</configuration>
I'm trying to run the javadoc:javadoc goal for Maven for my Java 1.7 project. I'd like to specify my customized stylesheet in /src/main/java/stylesheet.css to use when running the goal, but the default javadoc stylesheet is used instead.
I've tried adding the following to my pom.xml file, as the https://maven.apache.org/plugins/maven-javadoc-plugin/examples/stylesheet-configuration.html documentation on the Apache Maven site suggests:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<stylesheetfile>src/main/java/stylesheet.css</stylesheetfile>
</configuration>
</plugin>
</plugins>
</reporting>
But this doesn't get the desired result when I run the maven javadoc:javadoc goal. Any suggestions?
Update: I've tried with
<configuration>
<stylesheetfile>theme-irvine.css</stylesheetfile>
</configuration>
And with
<configuration>
<stylesheetfile>${basedir}/src/main/java/theme-irvine.css</stylesheetfile>
</configuration>
in my pom.xml file, and neither of those worked, either.
I am using the maven-feature-plugin
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>features-maven-plugin</artifactId>
<version>2.3.6</version>
<executions>
<execution>
<id>generate</id>
<phase>generate-resources</phase>
<goals>
<goal>generate-features-xml</goal>
</goals>
<configuration>
<bundles>src/main/resources/bundle.properties</bundles>
<kernelVersion>2.3.6</kernelVersion>
<outputFile>target/features.xml</outputFile>
</configuration>
</execution>
</executions>
</plugin>
This works pretty well but one of my generated features depends on the pax-cdi feature is there a way for me to get the plugin to add this for me? For example I have some dependencies defined in the bundle.properties file that cannot be resolved automatically, could I add a feature in this file as well?
You can add the feature as a maven dependency in your pom:
<dependency>
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-features</artifactId>
<version>0.8.0</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
This will result a feature.xml containing the pax-cdi features (providing that karaf-maven-plugin is configured with <aggregateFeatures>true</aggregateFeatures>).
You can also leave it to the container to pull in the pax-cdi feature. Just edit $KARAF_HOME/etc/org.apache.karaf.features.cfg where you can enlist your pax-cdi-features by adding the maven url to the list of featuresRepositories.
featuresRepositories=....
....,\
mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features
Then add pax-cdi to the list of boot features
featuresBoot=.....,pax-cdi,...
Karaf will start the bundles of pax-cdi when it boots, so that your bundles can find those cdi packages available.
I think that the karaf convention is that the pax-cdi feature should be provided by the container itself, so you don't need to add those bundles to your feature descriptor.
To use pax-cdi feature in karaf enter the following in your Karaf shell
features:addurl mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features
I am trying to chance the icon of the exe file while creating native bundling of javafx packaging.
I tried adding icon into pom.xml but till it wont work out for me as it gives default icon
Using Intellij IDEA IDE which contain an Pom.xml creating an package by command = mvn jfx:build-native
Here is my pom.xml:
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<mainClass>com.demoApp.testapp.testApplication</mainClass>
<!-- only required if signing the jar file -->
<keyStoreAlias>example-user</keyStoreAlias>
<keyStorePassword>example-password</keyStorePassword>
<permissions>
<permission>all-permissions</permission>
</permissions>
<icon>${basedir}/src/main/resources/images/logoIcon.ico</icon>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
I have added an icon path into pom.xml ${basedir}/src/main/resources/images/logoIcon.ico
that will run while native package execute but it wont work out for me
Is any other way to do it ?
Please suggest.
i tried fx tags in pom.xml using ant,here is my changes in pom.xml
<properties>
<javafx.tools.ant.jar>${env.JAVA_HOME}\lib\ant-javafx.jar</javafx.tools.ant.jar> </properties>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>create-launcher-jar</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target xmlns:fx="javafx:com.sun.javafx.tools.ant">
<taskdef
uri="javafx:com.sun.javafx.tools.ant"
resource="com/sun/javafx/tools/ant/antlib.xml"
classpath="${javafx.tools.ant.jar}"/>
<fx:application id="fxApp"
name="${project.name}"
mainClass="com.precisionhawk.flightplanner.FlightPlannerApp"/>
<fx:jar destfile="${project.build.directory}/${project.build.finalName}-launcher">
<fx:application refid="fxApp"/>
<fx:fileset dir="${project.build.directory}/classes"/>
</fx:jar>
<attachartifact file="${project.build.directory}/${project.build.finalName}-launcher.jar"
classifier="launcher"/>
<fx:deploy>
<fx:info>
<fx:icon href="${basedir}/src/main/deploy/logoIcon.ico"></fx:icon>
</fx:info>
</fx:deploy>
</target>
</configuration>
</execution>
</executions>
</plugin>
but it wont work out..
I just struggled with the same issue using Zonsky's great javafx-maven-plugin. As of version 1.5, which you also were using, the src/main/deploy directory will be added to the classpath. The icon you want to use could be added there and it will be available on the classpath for the native builder!
I added src/main/deploy/package/windows/myapp.ico there and it finally worked :)
For you:
Create src/main/deploy/package/windows/ folder
Add icon with name ${project.build.finalName}.ico
Run mvn jfx:build-native
I haven't played with it extensively - just got it to work and wanted to share. So if you want to use icon with different name, I don't know how. Not yet at least. The <icon>...</icon> section in the config section seems to be for webstart, so I haven't been using it.
Hope you get it to work!
You need to look at the logging while building a native app. That will tell you where the installer looks for the icon files and with wich name. For the default Windows native app it looks in ./package/windows/'appname'.ico
Can't remember where 'appname' comes from, but just look at the logging while building, it will tell you. (I use the Ant targets called from my pom btw)
you can do this:
`<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<vendor>YourCompany</vendor>
<mainClass>com.alan344.MapperGenApplication</mainClass>
<appName>mybatis-friend</appName>
<bundleArguments>
<icon>${project.basedir}/src/main/resources/image/icon.ico</icon>
</bundleArguments>
</configuration>
</plugin>`
I am currently working on a project that includes using JNotify to monitor when a directory/file has been created, renamed/modified, and deleted. The project is being built in Java 6, not Java 7. JNotify uses JNI to hook into the native OS to monitor the directory/file. My problem is that I need to get JNotify into our repo but I want it to be built so that the java.library.path (DLL) is packaged with the JNI JAR. How would I go about doing that in Maven?
I was able to find the solution I needed using the following maven plugin: http://code.google.com/p/mavennatives/
You must probably upload the jar manually to your archiva instance.
The repository format is fixed, so you will need to perform the rename after retrieving the artifact. That depends how you intend to use it after it is retrieved.
This is a common pattern is something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<stripVersion>true</stripVersion>
</configuration>
<executions>
<execution>
<id>copy-jnotify</id>
<configuration>
<includeArtifactIds>JNotify</includeArtifactIds>
<outputDirectory>${project.build.directory}/my-app</outputDirectory>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
You can use this with the appropriate list of artifacts that will all be copied into the target/my-app directory