Maven Jaxb2 xjc plugin error No schemas have been found - maven

These days I've spent some time on JAXB for converting XSD to Java Class and vice versa. Here's a very good tutorial for beginners, http://www.journaldev.com/1312/how-to-generate-java-classes-from-xsd-using-xjc-maven-plugin. I follow the steps strictly, but always get error when mvn clean install
Here's my pom.xml file.
<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>
<groupId>jd</groupId>
<artifactId>jd</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Plugin required to build java classes from XSD using XJC -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The name of your generated source package -->
<arguments>-extension -npa -b ${project.basedir}/src/main/java/com/moodys/jaxb/global.xjb</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
But when I type mvn clean install, it always give me error as following:
C:\Users\congy\Desktop\Work\workspace\JaxbFromClass>mvn clean jaxb2:xjc
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jd 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # jd ---
[INFO] Deleting C:\Users\congy\Desktop\Work\workspace\JaxbFromClass\target
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (default-cli) # jd ---
[INFO] Generating source...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.487s
[INFO] Finished at: Thu Jul 04 19:09:37 CST 2013
[INFO] Final Memory: 4M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.5:xjc (default-cli) on project jd: No schemas have been found -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Can anyone show me the cause or simply tell me what should I refer to for further information?
Another question is : according to this question Difference of Maven JAXB plugins, there's at least three jaxb plugins. So all of these plugins are all generated for the same purposes? If so ,why?
Thanks in advance!

As you did not provide any schemaDirectory, the plugin is trying to generate Java sources from all XML schema files in the default schema directory. You should configure the plugin according to the documentation :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>id1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/jaxb</outputDirectory>
<packageName>com.your.package.jaxb</packageName>
<schemaDirectory>src/main/xsd</schemaDirectory>
<schemaFiles>jaxb.xsd</schemaFiles>
</configuration>
</execution>
</executions>
</plugin>

Try to make sure that jaxb.xsd is present under src/main/resources, the plugin is waring since it coudn't find the scheme in the specified location.

We can use as below in pom.xml file
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>id1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<outputDirectory>src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
<packageName>com.subu.xsd.model</packageName>
<schemaDirectory>src/main/java/schemadir</schemaDirectory>
<schemaFiles>XYZ.xsd</schemaFiles>
</configuration>
</execution>
</executions>
</plugin>

The OP already got their answer, but I ran into this same problem for a different reason...
I introduced a new class that JAXB wasn't generating source for. This is because I used a parameterized constructor. Once I added a no-arg constructor the problem was fixed.

Related

maven-dependency-plugin usage to download dependency jars

Hoping someone can explain how to set the plugin options correctly.
I am looking to have a pom file that someone could execute an mvn command on to download all the jars of the dependencies (transitive included) defined in the pom (including their sources and javadoc jars) from Maven Central and copy them to a specified directory.
My question appears quite similar to maven-dependency-plugin ignores outputDirectory configuration but dwells on a slightly different aspect. Tried the approach advised in the accepted answer there but that didn't work.
pom file:
<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>
<groupId>gq.jetstream</groupId>
<artifactId>maven-download-sources-javadocs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<org.springframework.version>5.2.22.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
</dependencies>
<build>
<!-- <sourceDirectory>src</sourceDirectory> -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<classifier>sources</classifier>
<classifier>javadoc</classifier>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
<includeClassifiers>sources,javadoc</includeClassifiers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Executing mvn package against this pom doesn't do anything. The output for the goal execution was empty.
Alt 1: Tried the following command. This copied the javadoc jars only and not the binary jars and sources jars of the dependencies.
mvn dependency:copy-dependencies#copy-dependencies
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< gq.jetstream:maven-download-sources-javadocs >------------
[INFO] Building maven-download-sources-javadocs 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.3.0:copy-dependencies (copy-dependencies) # maven-download-sources-javadocs ---
[INFO] Copying spring-core-5.2.22.RELEASE-javadoc.jar to C:\projects\code\maven-download-sources-javadocs\target\dependency-jars\spring-core-5.2.22.RELEASE-javadoc.jar
[INFO] Copying spring-jcl-5.2.22.RELEASE-javadoc.jar to C:\projects\code\maven-download-sources-javadocs\target\dependency-jars\spring-jcl-5.2.22.RELEASE-javadoc.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.846 s
[INFO] Finished at: 2022-06-22T02:09:55+01:00
[INFO] ------------------------------------------------------------------------

Error during maven "clean install" with plug-in resolve

I try to to use clean install in Maven and get the error below. I have two questions:
Is this an error to be solved with a fair amount of work or is it such an esoteric error, that any attempt to solve it would end up in a long-term project?
Has anybody a solution in mind?
I can provide further info, if necessary. The java version is:
openjdk version "10.0.1" 2018-04-17
I'm running this on Ubuntu 18.04.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] DeepLearning4j Examples Parent
[INFO] DeepLearning4j Examples
[INFO] dl4j-spark-examples
[INFO] dl4j-spark
[INFO] datavec-examples
[INFO] DeepLearning4j CUDA special examples
[INFO] nd4j-examples
[INFO] Reinforcement Learning4j Examples
[INFO] lstm-hdfs
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DeepLearning4j Examples Parent 1.0.0-alpha
[INFO] ------------------------------------------------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-enforcer-plugin/1.0.1/maven-enforcer-plugin-1.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] DeepLearning4j Examples Parent ..................... FAILURE [ 1.359 s]
[INFO] DeepLearning4j Examples ............................ SKIPPED
[INFO] dl4j-spark-examples ................................ SKIPPED
[INFO] dl4j-spark ......................................... SKIPPED
[INFO] datavec-examples ................................... SKIPPED
[INFO] DeepLearning4j CUDA special examples ............... SKIPPED
[INFO] nd4j-examples ...................................... SKIPPED
[INFO] Reinforcement Learning4j Examples .................. SKIPPED
[INFO] lstm-hdfs .......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.774 s
[INFO] Finished at: 2018-05-01T21:23:04+02:00
[INFO] Final Memory: 8M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-enforcer-plugin:1.0.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-enforcer-plugin:jar:1.0.1: Could not transfer artifact org.apache.maven.plugins:maven-enforcer-plugin:pom:1.0.1 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Here is the pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-examples-parent</artifactId>
<version>1.0.0-alpha</version>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<name>DeepLearning4j Examples Parent</name>
<description>Examples of training different data sets</description>
<properties>
<!-- Change the nd4j.backend property to nd4j-cuda-8.0-platform, nd4j-cuda-9.0-platform or nd4j-cuda-9.1-platform to use CUDA GPUs -->
<nd4j.backend>nd4j-native-platform</nd4j.backend>
<!--<nd4j.backend>nd4j-cuda-9.1-platform</nd4j.backend>-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<shadedClassifier>bin</shadedClassifier>
<java.version>1.8</java.version>
<nd4j.version>1.0.0-alpha</nd4j.version>
<dl4j.version>1.0.0-alpha</dl4j.version>
<datavec.version>1.0.0-alpha</datavec.version>
<arbiter.version>1.0.0-alpha</arbiter.version>
<rl4j.version>1.0.0-alpha</rl4j.version>
<!-- For Spark examples: change the _1 to _2 to switch between Spark 1 and Spark 2 -->
<dl4j.spark.version>1.0.0-alpha_spark_1</dl4j.spark.version>
<datavec.spark.version>1.0.0-alpha_spark_1</datavec.spark.version>
<!-- Scala binary version: DL4J's Spark and UI functionality are released with both Scala 2.10 and 2.11 support -->
<scala.binary.version>2.11</scala.binary.version>
<hadoop.version>2.2.0</hadoop.version> <!-- Hadoop version used by Spark 1.6.3 and 2.2.1 (and likely others) -->
<guava.version>19.0</guava.version>
<logback.version>1.1.7</logback.version>
<jfreechart.version>1.0.13</jfreechart.version>
<jcommon.version>1.0.23</jcommon.version>
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
<maven.minimum.version>3.3.1</maven.minimum.version>
<javafx.version>2.2.3</javafx.version>
<javafx.runtime.lib.jar>${env.JAVAFX_HOME}/jfxrt.jar</javafx.runtime.lib.jar>
<aws.sdk.version>1.11.109</aws.sdk.version>
<jackson.version>2.6.6</jackson.version>
<scala.plugin.version>3.2.2</scala.plugin.version>
</properties>
<modules>
<module>dl4j-examples</module>
<module>dl4j-spark-examples</module>
<module>datavec-examples</module>
<module>dl4j-cuda-specific-examples</module>
<module>nd4j-examples</module>
<module>rl4j-examples</module>
<module>lstm-hdfs</module>
</modules>
<!-- Maven Enforcer: Ensures user has an up to date version of Maven before building -->
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-default</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[${maven.minimum.version},)</version>
<message>********** Minimum Maven Version is ${maven.minimum.version}. Please upgrade Maven before continuing (run "mvn --version" to check). **********</message>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<!-- Automated Code Formatting -->
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<configFile>${session.executionRootDirectory}/contrib/formatter.xml</configFile>
<directories>
<directory>dl4j-examples</directory>
<directory>dl4j-spark-examples</directory>
<directory>datavec-examples</directory>
<directory>dl4j-cuda-specific-examples</directory>
<directory>nd4j-examples</directory>
<directory>rl4j-examples</directory>
<directory>arbiter-examples</directory>
<directory>lstm-hdfs</directory>
</directories>
</configuration>
</plugin>
<plugin>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<version>0.0.11</version>
<configuration>
<failOnViolation>true</failOnViolation>
<onlyRunRules>
<rule>DuplicateDep</rule>
<rule>RedundantPluginVersion</rule>
<rule>VersionProp</rule>
<rule>DotVersionProperty</rule>
</onlyRunRules>
</configuration>
<executions>
<execution>
<id>pom-lint</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.lewisd</groupId>
<artifactId>lint-maven-plugin</artifactId>
<versionRange>[0.0.11,)</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>OpenJFX</id>
<activation>
<jdk>1.7</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-default</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>env.JAVAFX_HOME</property>
<message>You must set the environment variable JAVAFX_HOME to the installation directory of the JavaFX 2.0 SDK! (with Oracle JDK1.7, $JRE_HOME/lib/jfxrt.jar)</message>
</requireProperty>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${javafx.runtime.lib.jar}</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>${javafx.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Update jenkins selenium plugin to version 3.0.1

I want to update jenkins selenium plugin (latest version: 2.53.1).
I can configure selenium hub and nodes outside of jenkins and run my automated tests with latest browser versions (firefox 51.0.1, chrome 55.0.2883.87) successfully but I just want to use jenkins as hub.
So that's why I'm trying to integrate the newest version of the selenium-server-standalone (3.0.1) into Jenkins but it's not working.
Getting this error messages:
[WARNING] The POM for org.jenkins-ci.tools:maven-hpi-plugin:jar:1.117 is missing, no dependency information available
[WARNING] Failed to build parent project for org.jenkins-ci.plugins:selenium:hpi:2.53.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO]Building Jenkins Selenium Plugin 2.53.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-hpi-plugin:1.117:validate (default-validate) # selenium ---
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:display-info (display-info) # selenium ---
[INFO] Maven Version: 3.3.9
[INFO] JDK Version: 1.8.0_121 normalized as: 1.8.0-121
[INFO] OS Info: Arch: amd64 Family: unix Name: linux Version: 4.4.0-62-generic
[INFO]
[INFO] --- maven-enforcer-plugin:1.3.1:enforce (display-info) # selenium ---
[INFO] Restricted to JDK 1.7 yet org.seleniumhq.selenium:selenium-server-standalone:jar:3.0.1:compile contains org/openqa/selenium/chrome/ChromeDriver.class targeted to JDK 1.8
[WARNING] Rule 2: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
Found Banned Dependency: org.seleniumhq.selenium:selenium-server-standalone:jar:3.0.1
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 11.325 s
[INFO] Finished at: 2017-02-15T16:42:25+01:00
[INFO] Final Memory: 62M/1133M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (display-info) on project selenium: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
pom.xml of maven project:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fake</groupId>
<artifactId>fake</artifactId>
<packaging>pom</packaging>
<version>${selenium.version}</version>
<name>fake</name>
<properties>
<selenium.short.version>3.0</selenium.short.version>
<selenium.version>${selenium.short.version}.1</selenium.version>
<htmlunit.driver.version>2.20</htmlunit.driver.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<get
src="http://selenium-release.storage.googleapis.com/${selenium.short.version}/selenium-server-standalone-${selenium.version}.jar"
dest="${project.build.directory}/selenium-server-standalone-${selenium.version}.jar"
verbose="on" usetimestamp="true" />
<get
src="https://github.com/SeleniumHQ/htmlunit-driver/releases/download/${htmlunit.driver.version}/htmlunit-driver-standalone-${htmlunit.driver.version}.jar"
dest="${project.build.directory}/htmlunit-driver-standalone-${htmlunit.driver.version}.jar"
verbose="on" usetimestamp="true" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>selenium-server-standalone</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.build.directory}/selenium-server-standalone-${selenium.version}.jar</file>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>${selenium.version}</version>
<packaging>jar</packaging>
<localRepositoryPath>local_m2</localRepositoryPath>
</configuration>
</execution>
<execution>
<id>htmlunit-driver-standalone</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${project.build.directory}/htmlunit-driver-standalone-${htmlunit.driver.version}.jar</file>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver-standalone</artifactId>
<version>${htmlunit.driver.version}</version>
<packaging>jar</packaging>
<localRepositoryPath>local_m2</localRepositoryPath>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Code : https://github.com/jenkinsci/selenium-plugin
OS: Ubuntu 16.04.2; Eclipse Neon Java IDE ,openjdk version "1.8.0_121"
I've already tried it out with openjdk 1.7 as well but it's still not working.
I'm quite a newbie at this so I appreciate any help. Thanks a lot.
The root cause is simple : The Jenkins plugin's parent pom enforces by default to JDK7. Selenium libraries have moved on to using JDK8. That explains the error message arising from the enforcer plugin.
Here's how the enforcer plugin has been configured in the parent pom
<java.level>7</java.level>
<enforceBytecodeVersion>
<maxJdkVersion>1.${java.level}</maxJdkVersion>
<ignoredScopes>
<ignoredScope>test</ignoredScope>
</ignoredScopes>
<excludes>
<!-- Makes no sense to check core itself: -->
<exclude>org.jenkins-ci.main:jenkins-core</exclude>
<exclude>org.jenkins-ci.main:cli</exclude>
<exclude>org.jenkins-ci.main:jenkins-test-harness</exclude>
<!-- findbugs dep managed to provided and optional so is not shipped and missing annotations ok -->
<exclude>com.google.code.findbugs:annotations</exclude>
</excludes>
</enforceBytecodeVersion>
To fix this, you have two options [ I have never tried this, but its something that you can try and see if it helps ] (Both these options I am suggesting based on the recommendations from your parent pom itself )
Try passing the JVM argument -Djava.level=8 when you build the code.
Add an entry such as below to your pom file (This will cause enforcer plugin to perhaps ignore only the selenium libraries)
maven-enforcer-plugin
display-info
org.seleniumhq.selenium:selenium-java::jar:compile
org.seleniumhq.selenium:selenium-server::jar:compile
Hope that helps!
update
I spent more time looking at this and realised that moving over to selenium 3.0.1 for this plug-in was not very straight forward. I have tried doing the changes and raised a pull request for the same. You can take a look at the PR and see if that helps.
PS : I still have 3 tests failing in the PR. I haven't figured out how to get them to pass. But the PR should help you get started. You can directly checkout my branch and try building from there.

Why is PMD OK from command line, but does not work from within Maven?

After many years of successful use of PMD with Ant, I am now trying without success to get PMD to work from within Maven.
To illustrate my problem, I have created a simple Maven system (based upon the Maven tutorial "my-app" hello world program). It differs only in the inclusion of a line of code which should trigger a PMD error using the basic ruleset:
Boolean bar = new Boolean("true");
When I run PMD from the command line, the problem in the code is revealed:
run.sh pmd -d src/main/java -f text -R rulesets/java/basic.xml -language java
maven-pmd-example/src/main/java/com/mycompany/app/App.java:11 Avoid instantiating Boolean objects; reference Boolean.TRUE or Boolean.FALSE or call Boolean.valueOf() instead.
However, when I run pmd from within Maven, the problem in the code is not revealed:
-> mvn pmd:check
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-pmd-plugin:2.7.1:check (default-cli) # my-app >>>
[INFO]
[INFO] --- maven-pmd-plugin:2.7.1:pmd (pmd) # my-app ---
[WARNING] Unable to locate Source XRef to link to - DISABLED
[INFO]
[INFO] <<< maven-pmd-plugin:2.7.1:check (default-cli) # my-app <<<
[INFO]
[INFO] --- maven-pmd-plugin:2.7.1:check (default-cli) # my-app ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.375s
[INFO] Finished at: Sun Feb 03 15:38:02 HST 2013
[INFO] Final Memory: 12M/309M
[INFO] ------------------------------------------------------------------------
Here is the pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<minimumPriority>0</minimumPriority>
<rulesets>
<ruleset>rulesets/basic.xml</ruleset>
</rulesets>
<targetJdk>1.6</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
</project>
I have uploaded this example system to GitHub so you can see the entire example system (and download/play with it if you would like):
https://github.com/philipmjohnson/maven-pmd-example
It's because you have set the minimumPriority to 0, which will effectively prevent PMD from evaluating any rules at all (refer to this SO question for a discussion on priority).
Please refer to this section of the goal documentation for the PMD plugin for more information.
I'd suggest modifying the configuration to set the minimumPriority to 2 so that you can fail the build for BooleanInstantiation.
Hope this helps!

How to generate jar for maven parent project

Maven requires a parent project to have
<packaging>pom</packaging>
clause in the parent's pom.xml. When such a project installed, only a pom-file generated into the maven repository. Jar-file is not generated, no matter if the parent project has any Java code. That forces me to have extra empty parent projects, which is overkill. Logically, some of my libraries could be parents at the same time.
Is there a way to generate both pom and jar files for a parent project without removing/adding the packaging clause between installs?
Use Maven Jar Plugin and Maven Build Helper. Example POM:
<?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>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>test-${project.version}</file>
<type>jar</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Maven build results:
mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.7:attach-artifact (attach-artifacts) # test ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default) # test ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # test ---
[INFO] Installing /home/username/projects/test/pom.xml to /home/username/.m2/repository/test/test/1.0/test-1.0.pom
[INFO] Installing /home/username/projects/test/test-1.0 to /home/username/.m2/repository/test/test/1.0/test-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.805s
[INFO] Finished at: Thu Sep 06 13:33:20 EDT 2012
[INFO] Final Memory: 4M/119M
[INFO] ------------------------------------------------------------------------
A note on Maven practices:
Parent modules are typically where you define the dependencies and plugins used in common by all your child modules. It rarely has output of its own. You probably want to have a "distribution" sub-module that aggregates all your other module artifacts, rather than attempting to do it in the parent module.

Resources