spring-restdocs 1.1.0.BUILD-SNAPSHOT maven is not generating the adoc files - spring-restdocs

I followed the testng sample of spring-restdocs 1.1.0.BUILD-SNAPSHOT. I am able to generate the adoc file through gradle. But when I am using the maven its not generating the doc files.
Mmy pom.xml has the following details:
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*TestNgApplicationTests.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.2.1</version>
<executions>
<execution>
<id>generate-docs</id>
<phase>prepare-package</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html</backend>
<doctype>book</doctype>
<attributes>
<snippets>${snippetsDirectory}</snippets>
</attributes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/static/docs</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/generated-docs</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

Try to run using this command from your terminal:
$> mvn package
The generated files should be under /target.
generated snippets should be under /target/generated-snippets.
generated .html should be under /target/generated-docs.
Make sure you have your generated-snippets directory configured to /target directory on your test class:
#Rule
public RestDocumentation restDocumentation =
new RestDocumentation("target/generated-snippets");

Related

maven install failed on a javafx application

I have created a basic javafx project in eclipse using a maven archetype. When I run a maven install I get the following error. When I run the application in the IDE it works. When I try to run from the target folder it does nothing. Here is the error:
"Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (unpack-dependencies) on project testjavafx: Command execution failed. Cannot run program "C:\Program Files\Java\jdk-10.0.2..\bin\javafxpackager" (in directory "C:\Users\Stephen\Documents\eclipse-workspace\testjavafx"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]"
Here is my pom.xml generated from maven archetype:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.stevie</groupId>
<artifactId>testjavafx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>testjavafx</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.stevie.testjavafx.MainApp</mainClass>
</properties>
<organization>
<!-- Used as the 'Vendor' for JNLP generation -->
<name>Your Organisation</name>
</organization>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludeScope>system</excludeScope>
<excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/../bin/javafxpackager</executable>
<arguments>
<argument>-createjar</argument>
<argument>-nocss2bin</argument>
<argument>-appclass</argument>
<argument>${mainClass}</argument>
<argument>-srcdir</argument>
<argument>${project.build.directory}/classes</argument>
<argument>-outdir</argument>
<argument>${project.build.directory}</argument>
<argument>-outfile</argument>
<argument>${project.build.finalName}.jar</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>default-cli</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${java.home}/bin/java</executable>
<commandlineArgs>${runfx.args}</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>10</source>
<target>10</target>
<compilerArguments>
<bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>
Thank you for your help.

Maven cucumber reporting from eclipse not generating the reports as per this plugin

Trying to generate the reports as per the maven cucumber reporting
Link to maven cucumber reporting
Made the necessary changes in the pom.xml file as explained here tutorial on configuring reports
But the reports are getting generated in the simple html file but not as per the cucumber reports.
pom.xml
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.${java.version}</source>
<target>1.${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<!-- <testFailureIgnore>true</testFailureIgnore> -->
<includes>
<exclude>**/*RunCukesTest.java</exclude>
<!-- <include>**/*RunCukesTest.java</include> -->
</includes>
<!-- <excludes> <exclude>**/*RunCukesTest.java</exclude> </excludes> -->
</configuration>
</plugin>
<!-- This is for Cucumber Custom Report plug in we specify the configuration
details under configuration tag. -->
<!-- http://startingwithseleniumwebdriver.blogspot.com/2016/05/custom-cucumber-reporting-using-maven.html -->
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.11.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>CucumberReport</projectName>
<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
<!-- <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput> -->
<jsonFiles>
<param>${project.build.directory}/cucumber.json</param>
</jsonFiles>
<!-- <parallelTesting>false</parallelTesting> -->
<buildNumber>1</buildNumber>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
RunCukesTest.java
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"classpath:features"},
plugin = {"html:target/site/cucumber-pretty","json:target/cucumber.json"},
tags = {"#currentTest"},
glue={"helpers","stepDefinitions"},
monochrome = true
)
public class RunCukesTest{
}
Reports are generated like this
which are different from expected
POM.XML::
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<includes>
<include>**/TestRunner.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>4.5.0</version>
<executions>
<execution>
<id>execution</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- <projectName>imademethink_cucumber_advanced_reporting</projectName> -->
<outputDirectory>${project.build.directory}/site/cucumber-reports-advanced</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber/cucumber.json</cucumberOutput>
<skippedFails>true</skippedFails>
<enableFlashCharts>false</enableFlashCharts>
<!-- <buildNumber>885</buildNumber> -->
<buildNumber>8.4.1.2</buildNumber>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
all configuration was good,
made two changes.
removed pluginManagement tag in pom
Used cucumberOutput output directory instead of jsonFiles. For some reason jsonFiles was generating duplicate reports.
pom file,
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.${java.version}</source>
<target>1.${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<includes>
<exclude>**/*RunCukesTest.java</exclude>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.13.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Simplify360 Automation Test Report</projectName>
<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<buildNumber>8.4.1.2</buildNumber>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
You need to set flag as below
<checkBuildResult>true</checkBuildResult>
Find my answer in below question URL
Reports are not generated when the build is failed in Maven Cucumber Reports
Just make 2 changes, and there you go
remove the tag from pom.xml file.
provide the version explicitly for the maven-surefire-plugin.
ex:version: 2.22.1

How to generate xml report with scoverage maven plugin?

I'm trying to generate scoverage xml report to use it in Jenkins. But all I can get is the folder scoverage-classes with my .scala files. Here is a part of my pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<id>scala-compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>${scalatest.plugin.version}</version>
<configuration>
<junitxml>surefire-reports</junitxml>
<stdout>W</stdout>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<aggregate>true</aggregate>
</configuration>
</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>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>report
</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
Scalatest generates xml reports, but Scoverage does not. I've tried to run maven with different args like mvn scoverage:report, mvn scoverage:report site and so on. Nothing helps. What should I change in my pom to make it work?
It turned out that I have scala compiler plugin that is not supported by scoverage plugin. Also it looks like maven scala compiler plugin from org.scala-tools is outdated. Supported by scoverage plugins are:
net.alchim31.maven:scala-maven-plugin
com.google.code.sbt-compiler-maven-plugin:sbt-compiler-maven-plugin

Eclipse m2e overwrites buildNumber from buildnumber-maven-plugin

I'm using Eclipse m2e, buildnumber-maven-plugin, and templating-maven-plugin to create a filtered java file with ${buildNumber}.
Here is a sample from the src/main/java-templates/build.java file:
public static final String BUILDNUMBER = "${buildNumber}";
If I run "mvn generate-sources" on the command line, my filtered java file contains the generated buildNumber value. If I run "generate-sources" from within Eclipse using m2e, the filtered java file briefly contains the actual buildNumber but is quickly replaced with the original string "${buildNumber}"
The structure of the project is
CmbProduct/pom.xml
+-- Model/pom.xml
+-- other modules
The buildnumber-maven-plugin is run in the parent pom.xml because I use buildNumber to set a general <finalName> value for all sub-modules.
I have tried it with and without lifecycle-mapping for org.eclipse.m2e.
I did not notice any change.
I have several "echo" tasks in both pom.xml files for debug purposes. These show the correct/actual buildNumber when run.
Here is an abbreviated CmbProduct/pom.xml:
<?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>com.magnicomp</groupId>
<artifactId>Product</artifactId>
<!-- Do not change version EVER. This is used by MagniCompCommon and all other sub modules. -->
<version>1.0</version>
<packaging>pom</packaging>
<name>CMB Product</name>
<modules>
<module>Model</module>
<module>Common</module>
</modules>
<scm>
<!-- SCM used by buildnumber-maven-plugin and others -->
<connection>scm:git:git://sol:/vol/git/cmb.git</connection>
</scm>
<properties>
<!--
The canonical Product Version is defined below. This value is
automatically propagated to Java via plugin in the Modelproject.
The ${buildNumber} is automatically generated on-the-fly by
buildnumber-maven-plugin
-->
<!--
Product version defined primary version of product.
This is used instead of project.version because the later must
remain the same.
-->
<product.version.base>1.0.0</product.version.base>
<product.version.status>alpha1</product.version.status>
<product.version>${product.version.base}.${buildNumber}-${product.version.status}</product.version>
<!-- Version in 4 dot (digits + dot) format suitable for Windows file Version -->
<product.version.4dot>${product.version.base}.${buildNumber}</product.version.4dot>
<!-- Java version -->
<project.source.version>1.8</project.source.version>
<project.target.version>1.8</project.target.version>
<!-- MagniComp common -->
<failOnMissingWebXml>false</failOnMissingWebXml>
<hibernate.version>4.3.11.Final</hibernate.version> <!-- was 4.3.10.Final -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<texo.version>0.9.0-v201501182340</texo.version>
<emf.version>2.11.0-v20150123-0347</emf.version>
<!-- Vaadin -->
<vaadin.version>7.5.7</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<vaadin.icons.version>1.0.1</vaadin.icons.version>
<!-- Product specific -->
<javax.servlet.version>3.1</javax.servlet.version>
<jersey.glassfish.version>2.21</jersey.glassfish.version>
<bouncy.version>1.51</bouncy.version>
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
<maven.shade.plugin.version>2.4.1</maven.shade.plugin.version>
<jna.version>4.1.0</jna.version>
</properties>
<build>
<finalName>${project.artifactId}-${product.version}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<!-- We do not need a default assembly.xml
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
</configuration>
-->
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<versionRange>[1.4,)</versionRange>
<goals>
<goal>create</goal>
<goal>create-metadata</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<encoding>${project.encoding}</encoding>
<source>${project.source.version}</source>
<target>${project.target.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version> <!-- Keep in sync with pluginsManagement -->
<inherited>false</inherited> <!-- Run only for this level project -->
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal> <!-- Create buildNumber -->
<goal>create-metadata</goal> <!-- Create build.properties -->
</goals>
</execution>
</executions>
<configuration>
<!--
Auto update incremental integer as build number.
Without this it uses git revision.
-->
<format>{0,number,integer}</format>
<items>
<item>buildNumber</item>
</items>
<!-- Store buildNumber in given file. Use product.version so it resets each time version changes -->
<buildNumberPropertiesFileLocation>${basedir}/buildinfo/buildNumber-${product.version.base}-${product.version.status}.properties</buildNumberPropertiesFileLocation>
<!-- WORKAROUND: Make ${buildNumber} available to child modules -->
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
</configuration>
</plugin>
<plugin> <!-- Help identify buildNumber -->
<artifactId>maven-antrun-plugin</artifactId>
<inherited>false</inherited> <!-- Run only for this level project -->
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Build Number (buildNumber) is ${buildNumber}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- This plugin allows us to add "src-gen" as another source dir -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build.helper.maven.plugin.version}</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>src-gen</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng-unit.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
... snip ....
Here is Model/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>
<parent>
<groupId>com.magnicomp</groupId>
<artifactId>Product</artifactId>
<version>1.0</version>
</parent>
<artifactId>Model</artifactId>
<packaging>jar</packaging>
<build>
<resources> <!-- XXX ARE WE GOING TO USE THIS? -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>version.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<!-- Override eclipse error about "create-metadata" goal from above plugin -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>filter-sources</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<versionRange>[1.4,)</versionRange>
<goals>
<goal>create</goal>
<goal>create-metadata</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.3,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin> <!-- Aid with making sure buildNumber is available -->
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>echo-buildnumber-1</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Build number during validate is ${buildNumber}</echo>
</tasks>
</configuration>
</execution>
<execution>
<id>echo-buildnumber-2</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Build number during generate-sources is ${buildNumber}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin> <!-- Must be after buildnumber-maven-plugin due to ${buildNumber} -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<executions>
<!-- Take files in sourceDirectory and filter them to outputDirectory -->
<execution>
<id>filter-src</id>
<phase>generate-sources</phase>
<goals>
<goal>filter-sources</goal>
</goals>
<configuration>
<sourceDirectory>${basedir}/src/main/java-templates</sourceDirectory>
<outputDirectory>${basedir}/src-generated</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<!-- Copy the build.properties created by buildnumber-maven-plugin -->
<id>copy-build-properties</id>
<phase>validate</phase>
<goals> <goal>copy-resources</goal> </goals>
<configuration>
<outputDirectory>${basedir}/src/main/resources</outputDirectory>
<resources>
<resource>
<directory>${project.parent.basedir}/target/generated/build-metadata</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
... snip ...
Its been a while, but I got this work with the create-timestamp goal with the timestampFormat and timestampPropertyName configuration properties, and the by adding the runOnConfiguration true on the Eclipse m2e lifecycle mapping.
Build number plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<revisionOnScmFailure>just.say.no.scm.config.in.pom</revisionOnScmFailure>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
<configuration>
<timestampFormat>yyyyMMddHHmmssS</timestampFormat>
<timestampPropertyName>myBuildNumberVariable</timestampPropertyName>
<!-- formats the timestamp all together like 20160404141705123 and puts
it in the ${myBuildNumberVariable} buildProperty -->
</configuration>
</execution>
</executions>
</plugin>

Porting a Maven Java project that uses JavaCC to Scala

I am trying to port a Maven based Java project that uses JavaCC to Scala.
I am happy to leave the JavaCC generated classes in Java at least for now.
However the JavaCC generated class depends on the classes being converted.
The project builds fine from the original Java sources, but if I replace them with the Scala sources Maven tries to compile the JavaCC generated class first and does not see and of the symbols provided by the new code.
The problem then seems to be how to get Maven to generate the Java code first then compile the Scala code and the generated code together that the compiler can find all dependencies. The solution seems to be to add some magical incantation to pom.xml. What should that be though?
My current pom.xml is:
<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>bobj</groupId>
<artifactId>bobj</artifactId>
<version>0.9</version>
<packaging>jar</packaging>
<name>BOBJ algebraic specification and verification system</name>
<url>http://github.com/fh-wedel/BOBJ</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>scala-2.10</id>
<properties>
<scalaVersion>2.10.4</scalaVersion>
<scalaBinaryVersion>2.10</scalaBinaryVersion>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scalaVersion}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-swing</artifactId>
<version>${scalaVersion}</version>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>bobj.BOBJ</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javacc-maven-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>javacc</id>
<goals>
<goal>javacc</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<!-- work-around for https://issues.scala-lang.org/browse/SI-8358 -->
<arg>-nobootcp</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
<source>src/main/javacc</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I did not write this. I started with the pom.xml that came with the project and and added the parts for scala and build-helper-maven-plugin
which I copied from other sources. My Maven-fu is minimal so I would not be surprised if I am doing something deeply misguided.
It turns out I forgot set up the scala-maven-plugin declaration for a mixed scala java project
ie the scala-maven-plugin needs
<executions>
<execution>
<id>scala-process-resources</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-process-test-resources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
instead of the usual
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>