ScalaBuff is giving an error while parsing protobuf file - java

I am getting the below error:
[INFO] --- exec-maven-plugin:1.2.1:exec (protobuf-sources) # structure-idl ---
<unknown>:1:1: string matching regex `\z' expected but `s' found
syntax = "proto3";
The below dependency is there and what I am trying to achieve is generate both Scala and Java file from protobuf file
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>initialize</phase>
<configuration>
<tasks>
<mkdir dir="target/generated-sources/scalabuff" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>protobuf-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<!-- automatically creates the classpath using all project dependencies,
also adding the project build directory -->
<classpath/>
<argument>net.sandrogrzicic.scalabuff.compiler.ScalaBuff</argument>
<argument>--proto_path=src/main/protobuf</argument>
<argument>--scala_out=target/generated-sources/scalabuff</argument>
</arguments>
<sourceRoot>target/generated-sources/scalabuff</sourceRoot>
</configuration>
</plugin>

Related

How do I define schema directory in JAXB2 maven plugin version 2.4?

I am trying to define the directory for my schema in my pom.xml. I keep getting an error saying "Element schemaDirectory is not allowed here". I am guessing this element is not supported in this version. So how do define my schema directory in this version?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
</configuration>
</plugin>
Thanks in advance!
This is valid for older version eg. 1.5:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<schemaDirectory>${project.basedir}src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
For version 2.4, according to documentation there is no longer schemaDirectory tag https://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.4/xjc-mojo.html
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.basedir}src/main/java</outputDirectory>
<sources>
<source>${project.basedir}src/main/resources</source>
</sources>
</configuration>
</plugin>
For version 2.5.0
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/${specify.xsd}</source>
</sources>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
Then run mvn compile

Maven not building reactjs files into my jar file

I am using exec-maven-plugin to run my maven build to build my reactjs project into my jar file, however, it executes fine but when I go into my jar file, none of the reactjs files are present - only my java classes are present.
My pom.xml looks like the following:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>exec-npm-install</id>
<phase>generate-sources</phase>
<configuration>
<workingDirectory>${project.basedir}src\main\app</workingDirectory>
<executable>npm.cmd</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>exec npm build</id>
<phase>generate-sources</phase>
<configuration>
<workingDirectory>${project.basedir}/src/main/app</workingDirectory>
<executable>npm.cmd</executable>
<arguments>
<argument>run-script</argument>
<argument>build</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>

eirslett frontend-maven-plugin failing with 403 on yarn install

I am using eirslett frontend-maven-plugin to build war file but getting the below error:
[ERROR] error An unexpected error occurred:
"http://registry.npmjs.org/calendar-utils/-/calendar-utils-0.1.2.tgz:
Request failed \"403 Forbidden\"".
below is the pom.xml for how I used the plugin
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<execution>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<yarnVersion>${yarn.version}</yarnVersion>
<nodeDownloadRoot>https://nodejs.org/dist/</nodeDownloadRoot>
<npmDownloadRoot>http://registry.npmjs.org/npm/-/</npmDownloadRoot>
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>install --force</arguments>
</configuration>
</execution>
<execution>
<id>webpack build test</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>test</phase>
<configuration>
<arguments>run webpack:test</arguments>
<yarnInheritsProxyConfigFromMaven>true</yarnInheritsProxyConfigFromMaven>
</configuration>
</execution>
<execution>
<id>webpack build prod</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run webpack:prod</arguments>
<yarnInheritsProxyConfigFromMaven>true</yarnInheritsProxyConfigFromMaven>
</configuration>
</execution>
</executions>
</plugin>
I am having this problem in prod profile only
./mvnw -Pprod package -DskipTests
any pointers are welcome.

How to run embedded TomEE for integration tests with test resources

I have J2EE project based on maven. This project contains connection to database, which is set up via resources.xml and persistence.xml. Connection works fine for normal deployment.
My problem is, that i would like to run embedded TomEE server for integration tests. For these tests i need use inmemory database.
To start TomEE i use combination of maven plugins showed below.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.13</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>7.0.4</version>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<checkStarted>true</checkStarted>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<simpleLog>true</simpleLog>
</configuration>
</plugin>
When i start maven goal mvn install, server runs as expected, but with wrong DB connection. I did not find way, how to set up, that i need use src/test/resources instead of src/main/resources.
Do you know how to set up this plugin in way? I'am open to suggestions of similar solutions, which is simple and do not contains 'lot of' frameworks.
Thank you in advance.
After some investigation i found solution described below.
Three plugins were added into pom.
First plugin will start TomEE server for us.
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>7.0.4</version>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<checkStarted>true</checkStarted>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<simpleLog>true</simpleLog>
</configuration>
Second one will replace proper resources and persistence files.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>copy-test-persistence</id>
<phase>process-test-resources</phase>
<configuration>
<tasks>
<!--backup the "proper" files-->
<copy file="${project.build.outputDirectory}/META-INF/resources.xml" tofile="${project.build.outputDirectory}/META-INF/resources.xml.proper"/>
<copy file="${project.build.outputDirectory}/META-INF/persistence.xml" tofile="${project.build.outputDirectory}/META-INF/persistence.xml.proper"/>
<!--replace the "proper" files with the "test" version-->
<copy file="${project.build.testOutputDirectory}/META-INF/resources.xml" tofile="${project.build.outputDirectory}/META-INF/resources.xml"/>
<copy file="${project.build.testOutputDirectory}/META-INF/persistence.xml" tofile="${project.build.outputDirectory}/META-INF/persistence.xml"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>restore-persistence</id>
<phase>prepare-package</phase>
<configuration>
<tasks>
<!--restore the "proper" files -->
<copy file="${project.build.outputDirectory}/META-INF/resources.xml.proper" tofile="${project.build.outputDirectory}/META-INF/resources.xml"/>
<copy file="${project.build.outputDirectory}/META-INF/persistence.xml.proper" tofile="${project.build.outputDirectory}/META-INF/persistence.xml"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
Last plugin force 'clean' before install. Without this i had problem in case, when i forget clean project before install.
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>

Create symlink to the current jar package after mvn package

My jar file name is configured in pom.xml like this:
<finalName>MyApp-${project.version}</finalName>
I would like Maven ('mvn package') to create a symlink to the current jar file every time I run it, so that I have two files:
MyApp-1.0.3.jar
MyApp.jar (which is "ln -s MyApp-1.0.3.jar MyApp.jar")
You can use Exec Maven Plugin as below to achieve this goal:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.6.0</version>
<executions>
<execution>
<id>Version Calculation</id>
<phase>verify</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>ln</executable>
<arguments>
<argument>-fnsv</argument>
<argument>target/MyApp-${project.version}.jar</argument>
<argument>MyApp.jar</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
Use below goals to execute it:
mvn clean verify
You can use symlink task/goal of ant-run plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<symlink link="${project.build.directory}/${project.artifactId}.jar"
resource="${project.build.directory}/${project.artifactId}-${project.version}.jar"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
If you want the symlinks to have relative path, you can give relative path in resource like below
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<symlink link="${project.build.directory}/${project.artifactId}.jar"
resource="./${project.artifactId}-${project.version}.jar"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

Categories

Resources