tycho-p2-director-plugin does not seem to have a way to add a version number to the final ZIP file names. it produces
myproduct-win32.win32.x86.zip
myproduct-macosx.cocoa.x86.zip
myproduct-linux.gtk.x86.zip
while I'd like to have
myproduct-1.6.0-win32.zip
myproduct-1.6.0-linux32.zip
myproduct-1.6.0-macos.zip
what's the best way? rename with maven-antrun-plugin somehow? rename with maven resources plugin? anything elese?
From the bug report at https://bugs.eclipse.org/bugs/show_bug.cgi?id=357503 it seems that they've added the ability to change the filename of the zip files directly from Tycho 0.14.0. I'm using the following for my tycho-p2-director-plugin block.
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>0.16.0</version>
<executions>
<execution>
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
</execution>
<execution>
<id>archive-products</id>
<goals>
<goal>archive-products</goal>
</goals>
</execution>
</executions>
<configuration>
<products>
<product>
<id>MY_PRODUCT_ID</id>
<archiveFileName>MyProduct-${project.version}</archiveFileName>
</product>
</products>
</configuration>
</plugin>
The key bit is in the <configuration> section at the end, where you can specify the prefix of the zip file using the <archiveFileName> tag. The suffix of the file is still -<os>.<ws>.<arch>.<archiveExtension>, as one might hope.
Below is what I do in my project,
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-director-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>materialize-products</id>
<goals>
<goal>materialize-products</goal>
</goals>
<configuration>
<installFeatures>false</installFeatures>
<profile>Installer</profile>
</configuration>
</execution>
<execution>
<id>archive-products</id>
<goals>
<goal>archive-products</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ANT actions -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<!-- Rename the ZIP files -->
<execution>
<id>update-zip-files</id>
<phase>install</phase>
<configuration>
<target>
<!-- Rename the products -->
<move verbose="true" todir="${project.build.directory}/products">
<mapper type="regexp" from="^(Installer-)(.*)$$"
to="\1N-${maven.build.timestamp}-\2" />
<fileset dir="${project.build.directory}/products">
<include name="*.zip" />
</fileset>
</move>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The answer is not Tycho specific:
<build>
<finalName>myproduct</finalName>
</build>
Related
I'm using Quarkus with Kotlin and tried to generate Rest clients using this Quarkus extension https://github.com/quarkiverse/quarkus-openapi-generator.
I included the dependency and the mentioned plugin into the pom.xml
<dependency>
<groupId>io.quarkiverse.openapi.generator</groupId>
<artifactId>quarkus-openapi-generator</artifactId>
<version>0.9.0</version>
</dependency>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
When compiling everything gets generated correctly into target/openapi/quarkus/clients_json/api/DefaultApi.java
However, when trying to import the DefaultApi it throws an error that it can't find the class.
I've tried the suggestions from the following post maven can't add files in generated-sources for compilation phase and included
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/gen-java</source><!-- adjust folder name to your needs -->
</sources>
</configuration>
</execution>
</executions>
</plugin>
into the pom.xml as well but it didn't do anything.
Does anyone know how to change the output directory of the generated OpenApi files with Quarkus?
Just an FYI:
I did the following, and it worked
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/openapi</source>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
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");
I'm looking for help with the scala-maven-plugin for Maven. I would like to generate my Scaladoc but I'm having some problems with it.
I actually can create my Scaladoc typing the following command:
mvn scala:doc
The problem now is that I want to add some options when I generate the Scaladoc, such as -no-link-warnings.
Does anyone know how to do this? I have found a way (the code below works), but I don't think that's the way I should be done.
My pom file is:
<build>
...
<plugins>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<args>
<arg>-no-link-warnings</arg>
</args>
</configuration>
<executions>
<execution>
<id>Compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
EDIT
A better approach has been suggested by the user Tunaki on the first reply, you can see the code there.
Your configuration is entirely correct, although you could write it a bit diffently. Currently (forgetting the part about compiling the sources), you have:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<args>
<arg>-no-link-warnings</arg>
</args>
</configuration>
</plugin>
With such a configuration, you declare that every execution of the scala-maven-plugin will have the additional argument -no-link-warnings. This is because you are declaring it inside the global configuration element. You can have a configuration that is specific to an execution of the plugin, exactly like what you have for the compiling part:
<execution>
<id>Compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
This configuration will only be taken into account when the execution Compile will be invoked.
As such, it would be preferable to change your configuration to be specific to an execution of the plugin, because the argument -no-link-warnings is really specific to generating the Scaladoc.
This would be the final plugin declaration:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>Scaladoc</id>
<goals>
<goal>doc</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<args>
<arg>-no-link-warnings</arg>
</args>
</configuration>
</execution>
<execution>
<id>Compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
Then, when you package your project with mvn package for example, the Scaladoc will be automatically generated with the correct argument.
Following this Guide I ran the command
mvn assembly:assembly
and got the Build Failure of
Error reading assemblies: No assembly descriptors found.
I've looked at numerous questions on this, but to no avail.
From this post, I created a .xml with this inside:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<dependencySets>
<dependencySet>
<scope>runtime</scope>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>**/LICENSE*</exclude>
<exclude>**/README*</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/META-INF/services</directory>
<outputDirectory>META-INF/services</outputDirectory>
</fileSet>
</fileSets>
</assembly>
and included this in the pom.xml:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
</plugin>
but still no luck.
I'm pretty new to this as you can probably tell, how can I get this running?
~~EDIT~~
In the pom.xml I changed
<descriptor>jar-with-dependencies.xml</descriptor>
To
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
~~EDIT 2~~
pom.xml now contains this:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
~~EDIT 3~~
This pom.xml now works for me:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
For this to work, you need to create the file jar-with-dependencies.xml in src/main/assembly/ and this XML:
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
i.e. you need to specify the path to the file and the convention is to put the files into src/main/assembly/.
To use the ones provided by Maven, you need to use the descriptorRef element instead (wrapped in a descriptorRefs).
Also don't put the descriptor inside of the execution element or mvn assembly:assembly can't find it anymore (since you specifically moved it to the mvn package target).
[EDIT] I followed the tutorial myself and there is an important point which you might have missed: You need to select the correct archetype. In my case, that was 5 but the order can change. So read the whole list and look for the string openimaj-quickstart-archetype or things will break.
I have difficulties with configuring Cobertura code-coverage tool in Jenkins to work with mixed Java/Scala project. Java classes works ok, but Cobertura don't analyze Scala tests.
Scala-specific configuration in my pom.xml:
<version.scala.plugin>3.1.0</version.scala.plugin>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<check/>
</configuration>
<version>2.5.2</version
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<!--suppress MavenModelInspection -->
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<!--suppress MavenModelInspection -->
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
It works. It was some kind of proxy issue, once I made build healthy again and built it several times, correct code-coverage appeared.