No schemas have been found | XJC - maven

Can someone please help me on this issue. I have more than 2 schema files in the same directory and trying to generate the java classes using xjc in maven.
Here is my pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${jaxb2.version}</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<clearOutputDir>false</clearOutputDir>
<extension>true</extension>
<schemaFiles>${root.dir}/schemas/PnTCacheSchema.xsd</schemaFiles>
<schemaDirectory>${root.dir}/schemas/</schemaDirectory>
<packageName>com.superpages.nbt.gen.pnt</packageName>
<outputDirectory>${root.dir}/nbt/src</outputDirectory>
</configuration>
</execution>
<execution>
<id>xjc1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<clearOutputDir>false</clearOutputDir>
<extension>true</extension>
<schemaFiles>${root.dir}/schemas/AdCacheSchema.xsd</schemaFiles>
<schemaDirectory>${root.dir}/schemas/</schemaDirectory>
<packageName>com.superpages.nbt.gen.cache</packageName>
<outputDirectory>${root.dir}/nbt/src</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Getting this exception
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:1.6:xjc (default-cli) on project gypsygen: No schemas have been found -> [Help 1]

Try enclosing <plugins> tag inside <pluginManagement> tag.

Related

How to make reserve-network-port work with maven spring project

I am trying to implement reserve-network-port with my maven spring project.
My POM
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<portNames>
<portName>tomcat.http.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<executions>
<execution>
<goals>
<goal>verify</goal>
</goals>
<configuration>
<systemProperyVariables>
<build.profile.url>${build.profile.url}</build.profile.url>
<test.server.port>${tomcat.http.port}</test.server.port>
</systemProperyVariables>
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
${tomcat.http.port} is returning null for me.
I am also getting the prot no reserved when my maven build is started
[INFO] --- build-helper-maven-plugin:1.10:reserve-network-port (reserve-network-port) # account-service ---
[INFO] Reserved port 58140 for tomcat.http.port

Not able to get it test coverage in sonarqube

[enter image description here][1][enter image description here][2]I know many people got such similar problem. i show many answars, tried the sample code given on sonar site. that sample is working fine. Also i show following link
How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?
But nothing seems working in my case. Its not showing IT Test Coverage in sonarqube though mvn clean intsall is making jacoco folder in site where index.html is having coverage report.
i tried almost every thing on net but not able to resolve issue.
its a multi module project
I am using
java8.
sonarqube 4.5.6 with java plugin 2.5.1.
maven 3.0.5
please help me resolve this.
Below is parent module pom file
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.basedir}/target/jacoco.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/../target/jacoco.exec</dataFile>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
<propertyName>failsafe.argLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.basedir}/../target/jacoco-it.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<argLine>${failsafe.argLine}</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- automatic label creation -->
</plugins>
</build>
<!-- Plugin to generate unit test coverage in SonarQube 4.5.x report. -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<use>false</use>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven-surefire-report-plugin.version}</version>
<configuration>
<alwaysGenerateFailsafeReport>true</alwaysGenerateFailsafeReport>
<alwaysGenerateSurefireReport>true</alwaysGenerateSurefireReport>
<aggregate>true</aggregate>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*.mar</exclude>
<exclude>${jacoco.excludePattern}</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</reporting>
Properties in same pom file
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath> <!-- This is the default, put here to be explicit -->
<sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.language>java</sonar.language>
<sonar.java.binaries>${project.basedir}/../target/classes</sonar.java.binaries>
<jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<maven-surefire-report-plugin.version>2.19.1</maven-surefire-report-plugin.version>
<maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>2.16</maven-failsafe-plugin.version>
mvn clean install is creating jacoco folder with index.html for test coverage but mvn sonar:sonar is not showing it in sonarqube
what mistake i am making.
in mvn sonar:sonar, it builds successfully and one of the line is JaCoCoSensor: JaCoCo report not found.
what could be the reason
i seriously feel this a bug with jacoco or sonarqube. May be it would not be compatible with java 8 or something. I tried almost every thing. Many things are deprecated with sonar java plugin 2.5.1. Please help me, i need the solution desperately
Just tried it, and the sample project works perfectly. Please make sure you do the following:
git clone https://github.com/SonarSource/sonar-examples.git
cd projects/languages/java/code-coverage/combined ut-it/combined-ut-it-multimodule-maven-jacoco
mvn clean package
mvn sonar:sonar
Also - not sure if this is related, but you're using a very old version of the SQ Java plugin (2.5.1). I can only advise you to update it to latest version.
Well, i am not sure why the above code is not working but i tried same thing bit differently and miracle happened. Let me give the solution what it worked for me.
I removed the below code from parent pom and put it in all child pom. Also since i was using it in child module i used target/jacoco.exec instead of ${project.basedir}/../target/jacoco.exec and same for jacoco-it.exec.
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>target/jacoco.exec</destFile>
<propertyName>surefireArgLine</propertyName>
<append>true</append>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>target/jacoco.exec</dataFile>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>target/jacoco-it.exec</destFile>
<propertyName>failsafe.argLine</propertyName>
<append>true</append>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>target/jacoco-it.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
Additional information. following plugin which i mentioned in my question is not required if Test coverage is required only in sonar report. If there is requirement for code report separately then its required
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*.mar</exclude>
<exclude>${jacoco.excludePattern}</exclude>
</excludes>
</configuration>
</plugin>

Override filename in maven when deploying file

I generate zip file in maven-assembly-plugin with specific name and want be able to deploy it.
I define $[my-version} property in initialize phase and I successfully get the file, but when deoplying I get the following error:
[ERROR]
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli)
on project my-project: C:\Users\pr\work\my-project\target\target\my-file-${my-version}.zip not found.
-> [Help 1]
Code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<file>target/my-file-${my-version}.zip</file>
<repositoryId>releases</repositoryId>
<url>${nexus.url}/content/repositories/releases</url>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>my-file-${my-version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/deployment.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
The problem was in order of phases. When calling goal "deploy:deploy-file" directly, the phase "intialization" wasn't processed.
So, one of the ways is to call it explicitly:
mvn initialize deploy-file

Maven Plugin for calling Maven Plugins?

does anyone know any maven plugin that can call other maven plugins in a generic way? What I am searching for is anything like a proxy mechanism for scheduling plugin executions in a specific order.
The key is that I have to migrate a huge legacy project to maven which has plenty of ant macros that have to run in a specific order but with maven it is not possible to invoke the same plugin twice in one and the same phase with preserving the execution order when I need to intercept the two executions by the exectuion of a second plugin.
Assume the following: I have plugin A (native2ascii) and plugin B (replacer). Now my execution order must be A,B,A in just one phase. Sure, I can write it like that but the effective pom would look like A,A,B.
So it would be nice to have a 'proxy-plugin' (P) which would simply invoke the configured plugins. This way you could configure P(A),P(B),P(A) in one phase and the effective pom would be able to preserve the execution order.
Thanks so far!
I've tried out Wim's proposal like in the following but it turned out that the execution ids have no impact on the effective pom. The two executions of the replacer plugin are still combined and run before the native2ascii plugin.
Here is my pom:
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>step-1-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>src/main/order-test/test.txt</file>
<outputFile>target/test-replaced-1.txt</outputFile>
<replacements>
<replacement>
<token>t</token>
<value>xyz</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<id>step-2-native2ascii</id>
<phase>generate-sources</phase>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<workDir>target</workDir>
<includes>
<include>test-replaced-1.txt</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>step-3-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>target/test-replaced-1.txt</file>
<outputFile>target/test-replaced-2.txt</outputFile>
<replacements>
<replacement>
<token>f6</token>
<value>-</value>
</replacement>
<replacement>
<token>e4</token>
<value>></value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
And here is how it looks like in the effective pom (both replacer executions are run before the native2ascii execution):
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>step-1-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>src/main/order-test/test.txt</file>
<outputFile>target/test-replaced-1.txt</outputFile>
<replacements>
<replacement>
<token>t</token>
<value>xyz</value>
</replacement>
</replacements>
</configuration>
</execution>
<execution>
<id>step-3-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>target/test-replaced-1.txt</file>
<outputFile>target/test-replaced-2.txt</outputFile>
<replacements>
<replacement>
<token>f6</token>
<value>-</value>
</replacement>
<replacement>
<token>e4</token>
<value>></value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<id>step-2-native2ascii</id>
<phase>generate-sources</phase>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<workDir>target</workDir>
<includes>
<include>test-replaced-1.txt</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
And here is the output of the build:
...
[INFO] --- replacer:1.5.3:replace (step-1-replacer) # build-order-test ---
[INFO] Replacement run on 1 file.
[INFO]
[INFO] --- replacer:1.5.3:replace (step-3-replacer) # build-order-test ---
[INFO] Replacement run on 1 file.
[INFO]
[INFO] --- native2ascii-maven-plugin:1.0-beta-1:native2ascii (step-2-native2ascii) # build-order-test ---
[INFO] Includes: [test-replaced-1.txt]
[INFO] Excludes: []
[INFO] Processing /home/shillner/work/workspaces/dev/build-order-test/target/test-replaced-1.txt
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Take a look at mojo-executor plugin, it can be used to invoke other plugins - from pom.xml and also programmaticaly.
Example:
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor-maven-plugin</artifactId>
<version>#project.version#</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>execute-mojo</goal>
</goals>
<configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
</plugin>
<goal>list</goal>
<configuration>
</configuration>
</configuration>
</execution>
</executions>
</plugin>
There is no official support, but we are using execution ids in alphabetical order and this works fine for many years already.
Example:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>step-0-copy-resources</id>
<goals>
<goal>resources</goal>
</goals>
<phase>package</phase>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>step-1-build-assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/assembly/descriptor.xml</descriptor>
</descriptors>
<!-- don't attach assembly to be installed -->
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<execution>
<id>step-2-build-installer</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${basedir}/BuildInstaller.groovy</source>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>step-3-attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${basedir}/target/project-${project.version}.tar.gz</file>
<type>tar.gz</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Notice how each <id/> starts with "step-x" with x a number.

Failed to execute goal org.codehaus.mojo:exec-maven-plugin. Command execution failed

I have a maven project.To run cucumber test i have following configuration in my pom file.
<plugin>
<groupId>net.mynetwork</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>0.0.4</version>
<executions>
<execution>
<id>execution</id>
<phase>site</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>${project.name}</projectName>
<outputDirectory>${project.build.directory}/site/cucumber-html-reports</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<enableFlashCharts>false</enableFlashCharts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>cucumber</id>
<phase>test</phase>
<configuration>
<executable>src/scripts/cucumber.sh</executable>
<arguments>
<argument>${host}</argument>
<argument>${port}</argument>
<argument>${profile}</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
When i am executing mvn command.
mvn clean install
its giving me following error.
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (cucumber) Misconfigured argument, value is null. Set the argument to an empty value if this is the required behaviour.
Failed to execute goal net.mynetwork:maven-cucumber-reporting:0.0.4
Please suggest any solution and let me know if anything else needs to be share.
Looks like http://jira.codehaus.org/browse/MEXEC-104.
Try this instead:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>cucumber</id>
<phase>test</phase>
<configuration>
<executable>src/scripts/cucumber.sh</executable>
<commandlineArgs>${host} ${port} ${profile}</commandlineArgs>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>

Resources