Unable to build maven project - M1 - maven

I'm an on M1 MAC trying to use the Azul jdk: https://cdn.azul.com/zulu/bin/zulu8.62.0.19-ca-jdk8.0.332-macosx_aarch64.dmg
I've installed it (see outputs below):
java -version
openjdk version "1.8.0_345"
OpenJDK Runtime Environment (Zulu 8.64.0.19-CA-macos-aarch64) (build 1.8.0_345-b01)
OpenJDK 64-Bit Server VM (Zulu 8.64.0.19-CA-macos-aarch64) (build 25.345-b01, mixed mode)
javac -version
javac 1.8.0_345
My error comes when I do a mvn clean install -e. This is the output:
I've also upgraded the frontend-maven-plugin to 1.11.0, which I've seen is necessary for the M1. At this point, I'm not sure where to go. Below is the pom.xml for ems_react_ui
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.inc.gem</groupId>
<artifactId>ems_react_ui</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>com.inc</groupId>
<artifactId>gem</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<build>
<finalName>ems_react_ui</finalName>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>../ems/src/main/webapp/scripts/react</directory>
<includes>
<include>**/**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>./node</directory>
<includes>
<include>**/**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.11.0</version>
<configuration>
<workingDirectory>./</workingDirectory>
<environmentVariables>
<!-- Avoid certificates issues for npm install, needed behind a corporate proxy -->
<NODE_TLS_REJECT_UNAUTHORIZED>0</NODE_TLS_REJECT_UNAUTHORIZED>
</environmentVariables>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v12.14.1</nodeVersion>
<npmVersion>3.10.8</npmVersion>
</configuration>
</execution>
<execution>
<!-- npm runs in the docker context and needs to be normal user for execution -->
<id>npm config set user root</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>config set user root</arguments>
</configuration>
</execution>
<execution>
<id>npm i</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>i</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-react-to-webapp</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../ems/src/main/webapp/scripts/react/dist</outputDirectory>
<resources>
<resource>
<directory>./dist</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-mainjs-to-webapp</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>../ems/src/main/webapp/scripts/react/</outputDirectory>
<resources>
<resource>
<directory>./</directory>
<includes>
<include>main.js</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Output of echo $PATH =
/Users/danieljohnson/.pyenv/shims:/Users/danieljohnson/.pyenv/bin:/Users/danieljohnson/.nvm/versions/node/v10.24.1/bin:/usr/local/opt/python#3.7/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/python#3.7/bin/pip3:/usr/local/opt/python#3.7/bin/python3:/Applications/Postgres.app/Contents/Versions/latest/bin

Version 14.15.4 fixed this isse for me (and I removed the npm version)
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v14.15.4</nodeVersion>
</configuration>

Related

Maven: how to exec a pom twice with different profiles?

I want to make a build with Maven within a pom which can be built with two different profiles.
In other words, my task is to force the build in order that the build produces two different builds in the target folder as like I will execute "maven install -P" two times.
So, to be more clear:
one single invocation
two different results based on the profile associated in that time
I've tried the exec-maven-plugin but I'm not sure if is the correct way, because it's not doing what I desire.
How can I perform that?
Here's the pom I'm trying.
The tasks are:
copy resources from another project
replace content based on the profile
Build both profiles.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>MavenDoubleInstallation</artifactId>
<profiles>
<profile>
<id>profileA</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>profileA</env>
<token>/path/for/profileA</token>
</properties>
</profile>
<profile>
<id>profileB</id>
<properties>
<env>profileB</env>
<token>/path/for/profileB</token>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/${env}/result</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/../SourceProject/resources/result</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${basedir}/target/classes/${env}/result</basedir>
<includes>
<include>**/*.sh</include>
</includes>
<replacements>
<replacement>
<token>%%TOKEN%%</token>
<value>${token}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>build-profileA</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>maven</executable>
<arguments>
<argument>-P profileA -X</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>build-profileB</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>maven</executable>
<arguments>
<argument>-P profileB -X</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Integrate create-react-app into maven build process

I am trying to integrate a recently created ReactJs application into the build process of the rest of my larger maven based application. I have done this in the past for an AngularJs application using npm, Gulp, and Bower. The difference this time around is that I am using Yarn but also the create-react-app base application from Facebook which relies on the 'react-scripts' development dependencies.
Previously my pom.xml for the maven project that built the AngularJs app looked as so:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<name>MyApp Service</name>
<description>MyApp Service</description>
<parent>
...
</parent>
<profiles>
<profile>
<id>exec-unix</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<npmexec>npm</npmexec>
<gulpexec>gulp</gulpexec>
<bowerexec>bower</bowerexec>
</properties>
</profile>
</profiles>
<properties>
<frontendDir>src/main/myappui</frontendDir>
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>npm install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${npmexec}</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>${frontendDir}</workingDirectory>
</configuration>
</execution>
<execution>
<id>bower install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${bowerexec}</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>${frontendDir}</workingDirectory>
</configuration>
</execution>
<execution>
<id>gulp build</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${gulpexec}</executable>
<arguments>
<argument>prepare-for-maven-war</argument>
</arguments>
<workingDirectory>${frontendDir}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I am not particularly sure what to do about the 'react-scripts' part. I tried adding <yarnexec>yarn</yarnexec> with an execution for yarn install and yarn build but it didn't provide desired results.

How to unpack a war file copied from local directory using Maven Resources Plugin?

I am trying integrating CAS server with a Spring application. (I have configured CAS locally, in my Tomcat server and it is working properly). Using Maven Resources Plugin I copied the cas.war file to my Web app's target folder. But I need to unpack that cas.war file in order to overwrite some files that I have modified.
How can I unpack this war file which I have copied using Maven Resources Plugin`?
Here is my pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>cas</warName>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${maven-jetty-plugin.version}</version>
<configuration>
<webApp>
<contextPath>/cas</contextPath>
</webApp>
</configuration>
</plugin>
<!--Copy plugin-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<!--copy cas.war file-->
<execution>
<id>copy-initial-cas.war</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/cas</outputDirectory>
<resources>
<resource>
<directory>${CAS.LOCATION}/target</directory>
<includes>
<include>cas.war</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<!--copying deployerConfigContext file-->
<execution>
<id>copy-deployerConfigContext</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/cas/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>${basedir}/resources</directory>
<includes>
<include>deployerConfigContext.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<!--copying web.xml file-->
<execution>
<id>copy-web.xml</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${basedir}/target/cas/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>${basedir}/resources</directory>
<includes>
<include>web.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<!--copying casdatabase.properties file-->
<execution>
<id>copy-casdatabase.properties</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/cas/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>${basedir}/resources</directory>
<includes>
<include>casdatabase.properties</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!--unpacking plugin-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>unzip-war</id>
<phase>install</phase>
<configuration>
<tasks>
<echo message="unpack cas.war" />
<unzip src="${basedir}/target/cas/cas.war" dest="${basedir}/target/cas" overwrite="true"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
If you wish to override resources inside a war, you should be using the maven overlay method.

deploy zip created by grunt to maven repository

I use the frontend-maven-plugin to run a grunt build with maven.
I have the following pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.a.b</groupId>
<artifactId>kuku</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>0.0.19</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v0.10.33</nodeVersion>
<npmVersion>1.4.28</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<configuration>
<arguments>build-nightly --no-color</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The grunt task creates a zip file which is called kuku.zip. I want to deploy this zip file to a maven repository.
There are questions on deploying zip files to maven:
Jenkins "Post Build Action" to deploy zip on Maven repository
But here the situation is different because there already a jar is created and i want to attach an additional zip file and here i don't have another artifact.
How can i achieve this task with maven?
I followed the approach of maven-assembly-plugin.
First i defined an assembly descriptor.xml
<assembly>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>kuku</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
and here is the changed pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>a.b</groupId>
<artifactId>kuku</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>0.0.19</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v0.10.33</nodeVersion>
<npmVersion>1.4.28</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<configuration>
<arguments>build-nightly --no-color</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>descriptor.xml</descriptor>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

multiple assemble results

I need to keep a status created during an artifact proceeding. So I've got the idea to bundle these state into an own zip and unpacking it in the prepare phase. Additional shall be the real result deployed as well. This result is a bundle to created files, valuable within a next artifact.
I'm trying create two result zips, but during deploy the second assembly name is ignored and always myArtifact-version.zip is deployed.
Whats wrong?
Thanks in advance,
Sven
my pom looks like:
<project ...>
<artifactId>myArtifact</artifactId>
<groupId>de.myGroup</groupId>
<packaging>pom</packaging>
...
<dependencies>
<dependency>
<groupId>de.myGroup</groupId>
<artifactId>gen-status</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/config</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
... proceeding generation
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>results</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assemble/bundle-gen-results.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>status</id>
<phase>package</phase>
<goals><goal>single</goal></goals>
<configuration>
<descriptors>
<descriptor>src/assemble/bundle-gen-status.xml</descriptor>
</descriptors>
<finalName>gen-status-${project.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</build>
</project>
The assemblies are:
gen-results.xml:
<assembly ... >
<id></id>
<formats><format>zip</format></formats>
<baseDirectory></baseDirectory>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/export</directory>
<includes>
<include>something.*/**/*.*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
bundle-gen-status.xml
<assembly ... >
<id></id>
<formats><format>zip</format></formats>
<baseDirectory></baseDirectory>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/config</directory>
<includes>
<include>status.file</include>
</includes>
<outputDirectory>classes/scripts</outputDirectory>
</fileSet>
</fileSets>
</assembly>
You can use the attach-artifact goal of build helper maven plugin to achieve this.
This allows me attaching the status file only to the current artifact. But then I'm getting a dependency cycle, when trying to add the status artifact.
<project ...>
<artifactId>myArtifact</artifactId>
<groupId>de.myGroup</groupId>
<packaging>pom</packaging>
...
<dependencies>
<dependency>
<groupId>de.myGroup</groupId>
<artifactId>myArtifact</artifactId>
<classifier>status</classifier>
<version>${project.version}</version>
</dependency>
</dependencies>
...
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/config</outputDirectory>
<includeClassifiers>status</includeClassifiers>
</configuration>
</execution>
</executions>
</plugin>
...
exec
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>status</id>
<phase>package</phase>
<goals><goal>attach-artifact</goal></goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/config/status.file</file>
<type>file</type>
<classifier>status</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>

Resources