So we are migrating a Maven project to Bazel. In this project, we generated our Open API documentation from Java annotations and using the swagger-maven-plugin as follows:
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputFileName>swagger</outputFileName>
<outputPath>${project.basedir}/src/main/resources/webroot</outputPath>
<outputFormat>JSON</outputFormat>
<resourcePackages>
<package>com.example.package1</package>
<package>com.example.package2</package>
</resourcePackages>
<prettyPrint>true</prettyPrint>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
Is there a way to generate this file using a Bazel rule?
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 am using tycho-source-plugin and tycho-source-feature-plugin to generate plugin source jars and source features.
I am generating a p2 repository using tycho-p2-repository-plugin and a product using tycho-p2-director-plugin.
For the p2 repository, I was able to include source jars by adding a category.xml and appending ".source" to the id of all the features.
For the product, I can't find any documentation or examples for how to include source jars with the materialized product or the product archive.
Is it possible?
I've stumbled across this today during work.
Sorry for reviving this, but perhaps this helps someone.
The way it worked for me was to specify a source feature in my product file and let tycho generate sources and a source feature from an existing feature.
Product file:
<feature id="com.some.feature" installMode="root"/>
<feature id="com.some.feature.source" installMode="root"/>
In my "API" bundle that contributes source, I added this in the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>doc</id>
<goals>
<goal>plugin-source</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I created a feature project that references this bundle. In the pom.xml of this project I added:
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-source-feature-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>doc</id>
<goals>
<goal>source-feature</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>attached-p2-metadata</id>
<phase>package</phase>
<goals>
<goal>p2-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Finally, in the project's parent POM I added:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>attached-p2-metadata</id>
<phase>package</phase>
<goals>
<goal>p2-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
The product editor itself contains an error marker, but that can be ignored.
Tycho itself builds the product and the source attachment is automatically set in the running Eclipse IDE.
I am having a Maven project with Scala code and i want to generate the two jars based on the different Scala versions (2.10.6 and 2.11.8).
If someone please suggest the solution how i can achieve this in single maven install execution or if there is any other way of achieving this in Maven using some Maven plug in.
I am able to solve this problem using multiple executions.
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>scala-version-2.10</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<scalaVersion>2.10.6</scalaVersion>
<outputDir>${project.build.outputDirectory}/scala-2.10</outputDir>
</configuration>
</execution>
<execution>
<id>scala-version-2.11</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<scalaVersion>2.11.8</scalaVersion>
<outputDir>${project.build.outputDirectory}/scala-2.11</outputDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>scala-2.10</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<classifier>scala-2.10</classifier>
<excludes>
<exclude>scala-2.11/**</exclude>
<exclude>sparkScala/**</exclude>
<exclude>sparksql/**</exclude>
<exclude>*.timestamp</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>scala-2.11</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<classifier>scala-2.11</classifier>
<excludes>
<exclude>scala-2.10/**</exclude>
<exclude>sparkScala/**</exclude>
<exclude>sparksql/**</exclude>
<exclude>*.timestamp</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Create profiles that have dependency overridden for different versions of Scala. You will need to run mvn install on both profiles. For more information see: different-dependencies-for-different-build-profiles-in-maven
Also you need to alter artifact name / version in profiles to make distinction between those two.
I am trying to run a simple Scala Hello World program using scala-maven-plugin from the command line in my Ubuntu VM running in Win-7 host OS.
I tried to execute in the following two ways :-
mvn scala:run -DmainClass=com.infoobjects.HelloWorld
Declaring the main class in a launcher tag in pom.xml and then executing mvn scala:run from the command line
But I am getting ClassNotFoundException in either case.
Directory Structure :-
Project > src > main > scala > com > infoobjects > HelloWorld.scala
Thanks in advance.
Here's my pom.xml
<build>
<finalName>sparkplay</finalName>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<launchers>
<launcher>
<id>launcher1</id>
<mainClass>com.infoobjects.HelloWorld</mainClass>
</launcher>
</launchers>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
</plugins>
</build>
your pom.xml has schema's issue : <executions> should not be child of <configuration>. So everything under <executions> is ignored
see Maven Model
I have an applet that uses several external libs. The project requires the applet JAR is signed because I perform disk operations. Another requirement is that all libs are included in the applet jar . My first attempt working this way was to include all the JARs of the libraries in a local directory of the Eclipse project and include them in the Eclipse project. After that I exported the entire project as a non-executable JAR, getting run most libs. But some libraries are still not referenced and I can not run my application via applet completely. Is there any more appropriate way to use libs inside a signed applet JAR?
If you are using maven then you can extract all classes needed. The maven plugin will do this for you. It can also sign it if you have an jks file. Here is some setup for maven.
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>${basedir}/the jks.jks</keystore>
<alias>the alias</alias>
<storepass>the store pass</storepass>
<signedjar>${project.build.directory}/signed/${project.build.finalName}.jar</signedjar>
<verify>true</verify>
<jarPath>${project.build.directory}/${project.build.finalName}-jar-with-dependencies.${project.packaging}</jarPath>
</configuration>
</plugin>
</plugins>