Maven needs to run everytime after a file changes - java

My problem: I have to run maven clean site everytime a file is changed so that Eclipse runs the new version... Can someone help me? It's quite annoying to run clean site everytime.
This is (partially) my pom file:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<slick2d.version>1.0.2</slick2d.version>
<junit.version>4.12</junit.version>
<json.plugin.version>1.1.1</json.plugin.version>
<mockito.version>1.9.5</mockito.version>
<findbugs.annotations.version>1.3.2</findbugs.annotations.version>
<javadoc.plugin.version>2.10.3</javadoc.plugin.version>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<pmd.plugin.version>3.6</pmd.plugin.version>
<findbugs.plugin.version>3.0.3</findbugs.plugin.version>
<cobertura.plugin.version>2.7</cobertura.plugin.version>
</properties>
<dependencies>
<dependency> <!-- slick2D dependency -->
<groupId>org.slick2d</groupId>
<artifactId>slick2d-core</artifactId>
<version>${slick2d.version}</version>
</dependency>
<dependency> <!-- junit dependency -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency> <!-- json dependency -->
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>${json.plugin.version}</version>
</dependency>
<dependency> <!-- mockito dependency -->
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>${findbugs.annotations.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin> <!-- cobertura -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.plugin.version}</version>
<configuration>
<instrumentation>
<excludes>
<exclude>*/CoberturaIgnore.class</exclude>
<exclude>*/highscore/HighScore.class</exclude>
<exclude>*/pop/PopBehaviour.class</exclude>
<exclude>*/ui/*.class</exclude>
</excludes>
<ignoreMethodAnnotations>
<ignoreMethodAnnotation>spiceballs.CoberturaIgnore</ignoreMethodAnnotation>
</ignoreMethodAnnotations>
</instrumentation>
</configuration>
</plugin>
<plugin> <!-- checkstyle -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
<plugin> <!-- pmd -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.plugin.version}</version>
<configuration>
<skipEmptyReport>false</skipEmptyReport>
<includeTests>true</includeTests>
<rulesets>
<ruleset>pmd-rules.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin> <!-- findbugs -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.plugin.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<includeTests>true</includeTests>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin> <!-- javadoc report -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<configuration>
<failOnError>false</failOnError>
</configuration>
<reportSets>
<reportSet>
<id>default</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin> <!-- cobertura report -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.plugin.version}</version>
</plugin>
<plugin> <!-- checkstyle report -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
<plugin> <!-- pmd report -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.plugin.version}</version>
<configuration>
<skipEmptyReport>false</skipEmptyReport>
<includeTests>true</includeTests>
<rulesets>
<ruleset>pmd-rules.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin> <!-- findbugs report -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.plugin.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<includeTests>true</includeTests>
</configuration>
</plugin>
</plugins>
</reporting>

If you working within your workspace locally, you can just run -- clean compile --goals. When you are finally done and pushing to higher environments- DEV/TEST/pre-prod, then you would run all the recommended goals for your project.
Look into this link for more details on what each goal does-
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Related

Maven build jar with local dependencies

I want to build a jar including all dependencies with the maven-assembly-plugin.
I implemented some dependencies from the maven repository which works fine BUT I also implemented local dependencies and when running the jar I get NoClassDefFoundError.
I think that maven does not include the local dependencies to the jar.
I have a lot of local dependencies which I need to use and it would be a lot of work to install all of them manually. It would be the easiest way if it would be possible to inculde them like a path.
This is my 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>-</groupId>
<artifactId>-</artifactId>
<version>1.0-SNAPSHOT</version>
<name>-</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>bosch</groupId>
<artifactId>jdatepicker</artifactId>
<version>1.3.2</version>
<scope>system</scope>
<systemPath>${basedir}/localLibraries/jdatepicker-1.3.2.jar</systemPath>
</dependency>
.
.
.
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>engine.RQ1Tools</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>HelloFX</mainClass>
</configuration>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.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>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M6</version>
<configuration>
<tagNameFormat>v#{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Thank you for helping :)

Need help for a java runtime error - UnsatisfiedLinkError

I'm a newbie to Java, Maven and pretty much every Java library that I'm using. I've spent the last 4 hours trying to figure out this runtime error:
java.lang.UnsatisfiedLinkError: org.lwjgl.opengl.WindowsDisplay.setWindowProc(Ljava/lang/reflect/Method;)V
at org.lwjgl.opengl.WindowsDisplay.setWindowProc(Native Method)
at org.lwjgl.opengl.WindowsDisplay.<clinit>(WindowsDisplay.java:219)
at org.lwjgl.opengl.Display.createDisplayImplementation(Display.java:159)
at org.lwjgl.opengl.Display.<clinit>(Display.java:136)
at game.Game.init(Game.java:148)
at defaultPackage.CraftMania.main(CraftMania.java:52)
I don't think the code of Craftmania.main and Game.init is any useful, although feel free to ask for it and I will post it.
In my project I'm using Maven, here's the pom file:
<?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>org.craftmania</groupId>
<artifactId>CraftMania</artifactId>
<version>1.0-SNAPSHOT</version>
<name>defaultPackage.CraftMania</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<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>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl_util</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>java3d</groupId>
<artifactId>vecmath</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.slick2d</groupId>
<artifactId>slick2d-core</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<argLine>-Djava.library.path=/natives/windows/:${java.library.path}</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
<excludes>
<exclude>conf/*</exclude>
<exclude>natives/*</exclude>
<exclude>res/*</exclude>
</excludes>
</configuration>
</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>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<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>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>defaultPackage.CraftMania</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I cannot figure out a fix to this. Could it be a mismatch between the .dll file (which was alredy in the project) and my version of lwjgl?
Just in case, here's what my workspace looks like. The src directory is src/main/java/hereAreMyPackages
Any help is appreciated, thanks.

Unable to create executable Jar in Dataflow SDK 2.1.0

I created Jar with the following 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>XXXXXXXXXXXXX</groupId>
<artifactId>XXXXXXXXXXXX</artifactId>
<version>XXXXXXXXXXXXX</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<dependency.locations.enabled>false</dependency.locations.enabled>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:-processing</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>XXXXXXXXXXXXXXXX</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
<reportSets>
<reportSet>
<reports>
<report>summary</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<!--<version>3.0.5-SNAPSHOT</version> -->
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.7</version>
<configuration>
<rulesets>
<ruleset>/rulesets/java/basic.xml</ruleset>
<ruleset>/rulesets/java/design.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>com.google.cloud.dataflow</groupId>
<artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.30</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<!-- Hamcrest and JUnit are required dependencies of DataflowAssert, which
is used in the main code of DebuggingWordCount example. -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.7</version>
</dependency>
</dependencies>
maven command
mvn clean
mvn compile
mvn package
Jar Command to execute
java -jar XXXXXX-jar-with-dependencies.jar
--runner=DataflowRunner
--jobName=XXXXXXXXXX
--project=XXXXXXXXXX
--network=XXXXXXXXXX
--subnetwork=XXXXXXXXXXXX
--workerMachineType=XXXXXXX
--region=XXXXXXXXXX
--maxNumWorkers=XXX
--stagingLocation=XXXXXXXXXX
--tempLocation=XXXXXXXXXXXX
--dataflowJobFile=XXXXXXXXXX
The following error occurred
java.lang.IllegalArgumentException: Unknown 'runner' specified 'DataflowRunner', supported pipeline runners [DirectRunner]
at org.apache.beam.sdk.options.PipelineOptionsFactory.parseObjects(PipelineOptionsFactory.java:1615)
at org.apache.beam.sdk.options.PipelineOptionsFactory.access$400(PipelineOptionsFactory.java:104)
at org.apache.beam.sdk.options.PipelineOptionsFactory$Builder.as(PipelineOptionsFactory.java:291)
Caused by: java.lang.ClassNotFoundException: DataflowRunner
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
As a workaround for the above error, we added the following to the pom file and use DirectRunner only when testing.
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-direct-java</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
When executing with the above workaround, the following error occurred.
java.lang.IllegalArgumentException: Unable to infer a coder and no Coder was specified. Please set a coder by invoking Create.withCoder() explicitly.
at org.apache.beam.sdk.transforms.Create$Values.expand(Create.java:318)
at org.apache.beam.sdk.transforms.Create$Values.expand(Create.java:268)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:473)
at org.apache.beam.sdk.values.PBegin.apply(PBegin.java:56)
at org.apache.beam.sdk.Pipeline.apply(Pipeline.java:180)
at org.apache.beam.sdk.io.gcp.bigquery.BatchLoads.expand(BatchLoads.java:344)
at org.apache.beam.sdk.io.gcp.bigquery.BatchLoads.expand(BatchLoads.java:67)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:454)
at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:284)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expandTyped(BigQueryIO.java:1019)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:972)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:659)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:473)
at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:297)
Caused by: org.apache.beam.sdk.coders.CannotProvideCoderException: Unable to provide a Coder for com.google.api.services.bigquery.model.TableRow.
Building a Coder using a registered CoderProvider failed.
See suppressed exceptions for detailed failures.
As a workaround for the above error, setCoder is set, but the result does not change.
In SDK 1.9.0 we were able to create executable Jar with maven.
If Jar can be created, can you give me a hint of how to change pom file and how to run jar?
Have you tried including the beam-runners-google-cloud-dataflow-java dependency?
https://beam.apache.org/documentation/runners/dataflow/

How do I work correctly with profiles, classifiers and modules in Maven?

I'm trying to create a Maven configuration that supports the same code for two different environments. One environment is Java 6 with Seam, the other is Java 7 with JEE.
My project is a multi module project with a parent pom where I've configured two profiles. The interesting parts in the parent pom:
<profiles>
<profile>
<id>JDK7</id>
<properties>
<jdk.version>1.7</jdk.version>
<profile.classifier>with-beans-xml</profile.classifier>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>JDK6</id>
<properties>
<jdk.version>1.6</jdk.version>
<profile.classifier>without-beans-xml</profile.classifier>
</properties>
<!-- Identical parts left out for brevity -->
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
<excludes>
<exclude>src/main/resources/META-INF/beans.xml</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
In a sub module of this pom I need to reference specific versions of other modules to be sure they are all using the same build version of Java and should contain or not contain beans.xml.
This is how I've done that:
<parent>
<groupId>commons</groupId>
<artifactId>parent-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>some-module</artifactId>
<dependencies>
<dependency>
<groupId>commons</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
<classifier>${profile.classifier}</classifier>
</dependency>
</dependencies>
The properties decalared above resolves just fine, but the dependency called core above contains references to other modules that contain the core functionality of the entire project.
The dependencies in core doesn't resolve when I import that module into other modules.
This is the dependency hierarchy I'm expecting:
- some-module
- core
- some-other-module
However, after adding core as a dependency to another module, I explicitly need to add some-other-module for it to be available too, i.e. some-other-module is not transitive from referencing core.
Am I going about this the wrong way? It works just fine with the different versions, just that I have to add them explicitly which I'd rather not to avoid confusion when other users are going to use this.
Updated
By request, here is the full parent pom and one of the modules that are experiencing the problems with transitive dependencies.
parent 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>se.commons</groupId>
<artifactId>healthcheck-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>healthcheck-parent-pom</name>
<modules>
<module>healthcheck-core</module>
<module>healthcheck-xsd</module>
<module>healthcheck-jms</module>
<module>healthcheck-db</module>
<module>healthcheck-filesystem</module>
<module>healthcheck-http</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.home>${JAVA_1_7_HOME}</java.home>
</properties>
<profiles>
<profile>
<id>JDK7</id>
<!-- <activation> -->
<!-- <activeByDefault>true</activeByDefault> -->
<!-- </activation> -->
<properties>
<!-- Build properties -->
<jdk.version>1.7</jdk.version>
<profile.classifier>with-beans-xml</profile.classifier>
<bom.version>2.0.0.R</bom.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>bom</artifactId>
<version>${bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Default</effort>
<threshold>Default</threshold>
<xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
<failOnError>true</failOnError>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<targetJdk>${jdk.version}</targetJdk>
<configuration>
<omitVisitors>FindReturnRef</omitVisitors>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
<executions>
<execution>
<goals>
<goal>checkstyle</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<configLocation>${basedir}/../src/site/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency>
<!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<configuration>
<locales>sv</locales>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>JDK6</id>
<properties>
<!-- Build properties -->
<jdk.version>1.6</jdk.version>
<profile.classifier>without-beans-xml</profile.classifier>
<bom.version>2.0.0.R</bom.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>bom</artifactId>
<version>${bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<resources>
<resource>
<directory>src/main/resources/META-INF</directory>
<excludes>
<exclude>beans.xml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${profile.classifier}</classifier>
<excludes>
<exclude>src/main/resources/META-INF/beans.xml</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Default</effort>
<threshold>Default</threshold>
<xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
<failOnError>true</failOnError>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<targetJdk>${jdk.version}</targetJdk>
<configuration>
<omitVisitors>FindReturnRef</omitVisitors>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
<executions>
<execution>
<goals>
<goal>checkstyle</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<configLocation>${basedir}/../src/site/checkstyle.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency><!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<configuration>
<locales>sv</locales>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Default</effort>
<threshold>Default</threshold>
<xmlOutputDirectory>target/findbugs</xmlOutputDirectory>
<failOnError>true</failOnError>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<targetJdk>${jdk.version}</targetJdk>
<configuration>
<omitVisitors>FindReturnRef</omitVisitors>
</configuration>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.4</version>
<configuration>
<targetJdk>${jdk.version}</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<reportSets>
<reportSet>
<reports>
<report>cobertura</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<instrumentation>
</instrumentation>
<formats>
<format>xml</format>
<format>html</format>
</formats>
<instrumentation>
<includes>
<include>**/*.class</include>
</includes>
</instrumentation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
</plugin>
</plugins>
</reporting>
</project>
And here is one of the modules that use core as a dependency:
<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>
<parent>
<groupId>se.commons</groupId>
<artifactId>healthcheck-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>healthcheck-jms</artifactId>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>healthcheck-core</artifactId>
<version>${project.version}</version>
<classifier>${profile.classifier}</classifier>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.jms</groupId>
<artifactId>jboss-jms-api_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And finally, here is the pom of core:
<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>
<parent>
<groupId>se.commons</groupId>
<artifactId>healthcheck-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>healthcheck-core</artifactId>
<dependencies>
<dependency>
<groupId>se.commons</groupId>
<artifactId>healthcheck-xsd</artifactId>
<version>${project.version}</version>
<classifier>${profile.classifier}</classifier>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I finally gave up on the above solution after finding similar questions that never got a clear answer.
It doesn't seem to be possible to resolve transitive dependencies using a classifier, only the standard GAV.
I settled on a different artifactId to differentiate the projects instead.

Maven failing to run Junit Tests on mvn -test

I have some Selenium Webdriver tests that I'd like to run from command line using mvn -test. Problem is that I can clean, build and compile with no issues but no tests run. I get no message relating to test such as "There are no tests to run."
My junit tests are following the *test class naming convention.
I have compared my POM with another project that runs tests no problem and it is identical, bar the project name and location. The project which works is under my User directory but the one that doesn't is directly underneath c:\
I'm not proficient enough to be able to debug this with mn -x yet so any help much appreciated. Here is my POM:
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>websiteRegression</groupId>
<artifactId>websiteRegression</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>websiteRegression</name>
<url></url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Full access to hamcrest matchers
see https://github.com/hamcrest/JavaHamcrest
you can add hamcrest-core for the foundation matchers
and you can add hamcrest-library for more extensive libraries
or you can add hamcrest-all for everything if you don't want to think about it
-->
<!-- Junit 4.11 needs hamcrest 1.3 -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<!-- if we use junit-dep then we can bring in the full hamcrest -->
<!-- JUnit 4.10 depends on hamcrest 1.1 -->
<!--
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
</dependency>
-->
<!-- Use JUnit as our test framework -->
<!-- this gives us basic hamcrest -->
<!-- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency> -->
<!-- if I want to use a version of hamcrest above 1.1 with 4.10 then I need an exclusion -->
<!--
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
-->
<dependency>
<!-- bring in the full selenium deploy
we could be more selective and bring
only what we need -->
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.39.0</version>
</dependency>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<!-- I have added the build section to support importing into
IntelliJ automatically without throwing errors about wrong Java
Version. This basically says the source requires at least Java 1.7
and use a compiler that outputs Java 1.7 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>anyBrowserTests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>firefoxTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
<include>**/FireFoxOnlySuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ieTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>chromeTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>operaTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/AllBrowserSuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>failingOperaTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
<include>**/FailOnOperaSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>failingIETests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnIEOnlySuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>failingChromeTests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<includes>
<include>**/FailOnChromeAndOperaAndIESuiteTest.class</include>
<include>**/FailOnChromeAndOperaSuiteTest.class</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</reporting>
EDIT: Ok, I found it was a problem with Profiles - fixed!
EDIT: Ok, I found it was a problem with Profiles - fixed!

Categories