RED5. Maven deploy issue - spring

I am trying to publish an spring mvc application in Red5Pro server. (tomcat).
I use Maven as build tool, but it seems to not work properly, because the
compiled classes are not found in WEB-INF/classes. This is my project structure:
The project is found in RED5ProHome/webapps, but without the compiled classes. (only xml, jsp and html).
This is my pom.xml
<modelVersion>4.0.0</modelVersion>
<groupId>org.red5.example</groupId>
<artifactId>springmvc</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<build>
<finalName>springmvc</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
// all dependencies needed
</dependencies>
Another point is that I export my project as war, manually, it works.
Do you have any idea how can I solve this issue?
Thank you.

Related

PluginVersionResolutionException in Maven project when I set packaging to bundle

In my Maven project when I change the packaging type from 'jar' to 'bundle' most of my plugins (compiler, deploy, install, resources, surefire) lose their versions. Why is this?
My pom.xml is below:
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ui_4.4.35_patch</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>web.admin.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
There are two possible approaches. The one I use for my own projects is to keep the bundle packaging and add the maven plugin versions to a pluginManagement section in the pom.xml. For example:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<!-- Add you current 'plugins' section here. -->
</build>
In addition to the version, you can also add configuration to each plugin. If your project has a parent pom, it would be natural to add the pluginManagement section there instead of in your bundle module.
Alternatively, as suggested by #khmarbaise, you can use jar packaging and just use the maven-bundle-plugin to generate the manifest. That approach is described in the plugin documentation page.

Checkstyle uses unpredictable config file

We have a maven project which includes checkstyle as well as pmd as analysers.
The problem is checkstyle sometimes takes my configured and modified google_checks.xml file, sometimes it uses a vanilla goole_checks.xml file and throws checkstyle errors, which are valid for the file it uses but I have no idea where it gets that file from. My pom looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<!-- checkstyle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- google checks -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>google_checks.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
<violationSeverity>warning</violationSeverity>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.20</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.12.0</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<failOnViolation>true</failOnViolation>
<printFailingErrors>true</printFailingErrors>
</configuration>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<!-- PMD -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.12.0</version>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
<!-- JXR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</reporting>
</project>
I removed some parts from the pom that are unrelevant I think.
The full project lies here: https://code.toold.xyz/Hochschule/WebAnServer/src/branch/mavenSetup/CueBox_source
When first executing a mvn clean it works reliably, but when I do a mvn compile and then without changing anything do a mvn compile again. It sometimes throws a lot of errors, about indents... which I removed from the google_checks.xml. It creates a checkstyle-checker.xml in the target folder, and it sometimes contains stuff that isn't in my google_checks.xml file, it looks more like the original google_checks.xml file.
Do you have any idea what causes this problem?
It seems like the issue was with the name google_checks.xml I renamed it and tested it now it works flawless all the time. It seems like maven interpreted the google_checks.xml not as a file name but as a refernce and downloaded it or extracted it from somewhere
If someone is here that knows exactly if this happened... please explain, I'll accept your answer :)

Checker framework cant resolve symbol<annotatedJdk>${org.checkerframework:jdk8:jar}</annotatedJdk> issue

Im trying to add Checker Framework via Maven repository i followed checker framework manual steps but i got this error on intelij ide
someone else mentioned having same issue on Google groups please any help is appreciated
my maven package is like this
<properties>
<annotatedJdk>${org.checkerframework:jdk8:jar}</annotatedJdk>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>jdk8</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<Xmaxerrs>10000</Xmaxerrs>
<Xmaxwarns>10000</Xmaxwarns>
</compilerArguments>
<annotationProcessorPaths>
<path>
<groupId>org.checkerframework</groupId>
<artifactId>checker</artifactId>
<version>2.5.1</version>
</path>
</annotationProcessorPaths>
<annotationProcessors><annotationProcessor>org.checkerframework.checker.nullness.NullnessChecker</annotationProcessor>
</annotationProcessors>
<compilerArgs>
<arg>-AprintErrorStack</arg>
<arg>-Xbootclasspath/p:${annotatedJdk}</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
tell me if miss any steps it also does not allow deleting that line with error
Assuming that the project is built by Maven from command line correctly, this looks like IntelliJ IDEA highlighting issue: IDEA-129269/IDEA-187553.
The way I was able to avoid this issue is to declare the properties as follows:
<checkerframework.version>2.5.6</checkerframework.version>
<annotatedJdk>${settings.localRepository}/org/checkerframework/jdk8/${checkerframework.version}/jdk8-${checkerframework.version}.jar</annotatedJdk>
Then re-import the Maven project.
Also note that with this it may not be necessary to configure the maven-dependency-plugin either.

Difference between plugins in project->build->pluginManagement and project->build

A snippet of my pom looks something like:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>1.0-alpha-7</version>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<configuration>
<updateDependencies>true</updateDependencies>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
</plugins>
</build>
Can anybody explain the difference between the <plugins> listing under project->build->pluginManagement and project->build>?
From the POM documentation at http://maven.apache.org/pom.html
pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way,
except that rather than configuring plugin information for this
particular project build, it is intended to configure project builds
that inherit from this one. However, this only configures plugins that
are actually referenced within the plugins element in the children.
The children have every right to override pluginManagement
definitions.

maven-war-plugin always running even without child pom.xml reference...why?

I am specifying:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<outputDirectory>C:\apache-tomcat-7.0.42\webapps</outputDirectory>
</configuration>
</plugin>
.
.
.
However, even though I do not specify anything in the respective children pom.xml, the war file is still being moved to that output directory.
As far as I know, pluginManagement is only there for reference from the children pom right?
Thank you for your help
By default Maven will invoke the maven-war-plugin war:war goal as part of the package phase if you specify <packaging>war</packaging> in your pom.xml
Since you have a <pluginManagement> stanza for maven-war-plugin specifying a custom <outputDirectory> in your parent pom.xml your child pom.xml will use this property when you run the package phase.
http://maven.apache.org/plugins/maven-war-plugin/usage.html

Resources