Rinsim, compile executable file failed, with maven dependency - rinsim

I try to get a executable file for my code using this maven plug from How can I create an executable JAR with dependencies using Maven?. However it ends up with the error Failed to execute goal com.mycila:license-maven-plugin:3.0:check (check-license) on project rinsim-example: Execution check-license of goal com.mycila:license-maven-plugin:3.0:check failed: Cannot read header document LICENSE_HEADER. Cause: Resource LICENSE_HEADER not found in file system, classpath or URL: no protocol: LICENSE_HEADER -> [Help 1]>
this is the part of my maven file:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.github.rinde.rinsim.examples.project.DDRP</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Thank you.

It seems like you've copied part of the RinSim pom.xml, including the license-maven-plugin? You should probably remove the license-maven-plugin plugin execution, as that is the source of this error message. This is the definition of the license-maven-plugin in RinSim:
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.mycila</groupId>
<artifactId>
license-maven-plugin
</artifactId>
<versionRange>
[2.11,)
</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
Alternatively, you can choose to use the license-maven-plugin. This plugin allows you to set a license header on every source file.

Related

Maven Assembly : How to generate a zip file for each environment ?

I have a static project with html, js, css and conf files like this :
project
- static
- conf
conf-int.json
conf-rec.json
conf-prd.json
-js
-html
-images
- pom.xml
- assemblyDescriptor.xml
Here is my assembly descriptor :
<id>zip</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>static/conf/</directory>
</fileSet>
</fileSets>
</assembly>
Here is my build conf in pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>trigger-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I want to generate my zip with either conf-int.json or conf-rec.json or conf-prd.json corresponding to differents environments i have. If it were a java project i would use profil maven with profil and/or classifier. But i don't know how to generate a zip file for each environment with maven-assembly. Could you give me some advice please ?
You can have multiple execution defined in your assembly plugin (each with distinct execution id and different assembly descriptor file). In the respective descriptor you define which file to include.

move the maven-onejar generated jar to a custom location

I am using the onejar-maven-plugin to generate the jar for my project and it all goes well. But, when I try to change it to a sub-folder, for eg. dist, the jar from maven-jar-plugin gets generated, not the jar from onejar.
The onejar plugin does not have an output directory option.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}/dist</outputDirectory>
<archive>
<manifest>
<mainClass>com.ss.itempriceclient.ItemPriceUploader</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.dstovall</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<classifier>onejar</classifier>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
How do I change the output directory of the onejar generated file to a subfolder, eg. dist?
I finally went with maven-assembly-plugin. Has lots of configuration options.

m2 release plugin couldn't recognize assembly file with parameterized name

In my POM.xml file, I am using assembly plug in. I want the build to assemble things based on the assembly file, whose name is parametrized. The build works fine. However, if I use m2 release plug in using perform release action in jenkins, the release plugin could not substitute the value for $env and pick up the assembly.xml file. I get the following exception.
Caused by: org.apache.maven.plugin.assembly.io.AssemblyReadException: Error locating assembly descriptor: src/main/assembly/${env}.xml
I have attached the log and POM file.
POM file build portion:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
<execution>
<id>dist</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuraenter code heretion>
<descriptors>
<descriptor>src/main/assembly/${env}.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>

How to have a pom.xml but prevent Maven being used for building?

I have a project for which I have created a pom.xml. However, I'm not using Maven as my build system, I am using something else (e.g. ANT). But I want the pom.xml to exist for the use of other tools, e.g. IDEs. How can I make sure, that if someone downloads my project and tries to build it with Maven, they will get a clear indication that they are doing the wrong thing?
Add the following to pom.xml:
<properties>
<maven.build.not.supported>
Do not use Maven to build this module. Please see README.html for
instructions on how to build it.
</maven.build.not.supported>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>fail-clean-lifecycle</id>
<phase>pre-clean</phase>
<configuration>
<tasks>
<fail message="${maven.build.not.supported}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>fail-default-lifecycle</id>
<phase>validate</phase>
<configuration>
<tasks>
<fail message="${maven.build.not.supported}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>fail-site-lifecycle</id>
<phase>pre-site</phase>
<configuration>
<tasks>
<fail message="${maven.build.not.supported}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Since we cannot apparently bind a plugin execution to multiple phases, we need to repeat the execution block three times, one for each of the built-in lifecycles (clean, default and site). To avoid duplication of the failure message, we store it in a Maven property and reuse that property in each execution. In each execution we bind to the first phase of the lifecycle to fail it immediately.

Installing a wsdl file into a Maven repository

I'm trying to install a wsdl file into a remote Maven repository so I can reference it in a CXF project as per this blog post.
I'm sure it could be done manually, but I want an actual maven project so I can make use of the release plugin for tagging etc.
Has anybody got experience with this?
You can use the build helper maven plugin to do this. Here is an indicative code snippet
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${wsdlLocation}/project.wsdl</file>
<type>wsdl</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build.

Resources