I am trying to package my front-end with my back-end, reactjs and java spring boot. I am getting this error and I can´t find a way to solve it. I got the latest npm, node and react installed.
Here is my 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>integritaback</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>integritaback</name>
<description>Projeto Clinica Integrita</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.12.1</version>
<executions>
<!-- installing node and npm -->
<execution>
<id>Install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v18.12.1</nodeVersion>
<npmVersion>8.19.2</npmVersion>
</configuration>
</execution>
<!-- running npm install -->
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<!-- build our production version -->
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
<configuration>
<nodeVersion>v18.12.1</nodeVersion>
<workingDirectory>src/main/Integrita</workingDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>Copy JavaScript app into SpringBoot</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/classes/static</outputDirectory>
<resources>
<resource>
<directory>src/main/Integrita/build</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
So when I try to run .\mvnw clean install it goes fine until this error appear:
[INFO] --- frontend-maven-plugin:1.11.3:npm (npm install) # integritaback ---
[INFO] Running 'npm install' in C:\Users\LuisR\Documents\Integrita\integritaback\src\main\Integrita
[INFO] npm ERR! code ERESOLVE
[INFO] npm ERR! ERESOLVE could not resolve
[INFO] npm ERR!
[INFO] npm ERR! While resolving: #react-pdf/renderer#3.0.1
[INFO] npm ERR! Found: react#18.2.0
[INFO] npm ERR! node_modules/react
[INFO] npm ERR! react#"^18.2.0" from the root project
[INFO] npm ERR! peer react#">=16.8.0" from #emotion/react#11.10.4
[INFO] npm ERR! node_modules/#emotion/react
[INFO] npm ERR! #emotion/react#"^11.10.4" from the root project
[INFO] npm ERR! peer #emotion/react#"^11.0.0-rc.0" from #emotion/styled#11.10.4
[INFO] npm ERR! node_modules/#emotion/styled
[INFO] npm ERR! #emotion/styled#"^11.10.4" from the root project
[INFO] npm ERR! 4 more (#mui/material, #mui/styled-engine, #mui/system, #mui/x-date-pickers)
[INFO] npm ERR! 4 more (#mui/material, #mui/styled-engine, #mui/system, #mui/x-date-pickers)
[INFO] npm ERR! 39 more (#emotion/styled, ...)
[INFO] npm ERR!
[INFO] npm ERR! Could not resolve dependency:
[INFO] npm ERR! peer react#"^16.8.6 || ^17.0.0" from #react-pdf/renderer#3.0.1
[INFO] npm ERR! node_modules/#react-pdf/renderer
[INFO] npm ERR! #react-pdf/renderer#"^3.0.1" from the root project
[INFO] npm ERR!
[INFO] npm ERR! Conflicting peer dependency: react#17.0.2
[INFO] npm ERR! node_modules/react
[INFO] npm ERR! peer react#"^16.8.6 || ^17.0.0" from #react-pdf/renderer#3.0.1
[INFO] npm ERR! node_modules/#react-pdf/renderer
[INFO] npm ERR! #react-pdf/renderer#"^3.0.1" from the root project
[INFO] npm ERR!
[INFO] npm ERR! Fix the upstream dependency conflict, or retry
[INFO] npm ERR! this command with --force, or --legacy-peer-deps
[INFO] npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
[INFO] npm ERR!
[INFO] npm ERR! See C:\Users\LuisR\AppData\Local\npm-cache\eresolve-report.txt for a full report.
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR! C:\Users\LuisR\AppData\Local\npm-cache\_logs\2023-01-03T12_02_46_084Z-debug-0.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.384 s
[INFO] Finished at: 2023-01-03T09:02:49-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.11.3:npm (npm install) on project integritaback: Failed to run task: 'npm install' failed. org.apache.commons.exec.Ex
ecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Can anyone help me out. I don´t know what else to do.
Related
I am using JDK 1.8 and Maven using Eclipse IDE. I want to analyze my project on SonarQube 6.6. Here is my pom.xml file:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ADDITION</groupId>
<artifactId>Addition</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId> <!-- NOT org.junit here -->
<artifactId>junit-dep</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin -->
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And this is the output with error:
(localhost:9000 is the default port for SonarQube and it is working fine. But the problem is I cannot import my maven project to sonar. If anyone finds the solution, please help.
Thank you.)
C:\eclipse-workspace\Addition>mvn sonar:sonar
[INFO] Scanning for projects...
[WARNING] The artifact org.codehaus.mojo:sonar-maven-plugin:jar:3.9.1.2184 has been relocated to org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.9.1.2184: SonarQube plugin was moved to SonarSource organisation
[INFO]
[INFO] -----------------< ADDITION:Addition >-----------------
[INFO] Building Addition 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.9.1.2184:sonar (default-cli) # Addition ---
[INFO] User cache: C:\Users\arghy\.sonar\cache
[ERROR] SonarQube server [http://localhost:9000] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.057 s
[INFO] Finished at: 2022-04-01T13:58:31+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project Addition: Unable to execute SonarScanner analysis: Fail to get bootstrap index from server: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000: Connection refused: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Looks like localhost resolves to the ipv6 adress, maybe sonarqube doesn't support that. What happens if you change http://localhost:9000 to http://127.0.0.1:9000?
I want to set main class in pom.xml to run exec:java I checked lots of resources but still have the same error.
I tried putting it in under execution tag.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.mertilovski.app.Game</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
My main class in under app directory.
TicTacToe/TicTacToe-Game/src/main/java/com/mertilovski/app
pom.xml is in TicTacToe directory.
That is where I run
mvn exec:java -Dexec.mainClass="com.mertilovski.app.Game"
I tried making an package com.mertilovski.app; declaration on top.
mvn exec:java -Dexec.mainClass="src.main.java.com.mertilovski.app.com.mertilovski.app.Game
"
Result is :
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------
------------
[INFO] Building TicTacToe-Game 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------
------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate #
TicTacToe-Game >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate #
TicTacToe-Game <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # TicTacToe-
Game ---
[WARNING]
java.lang.ClassNotFoundException: com.mertilovski.app.Game
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:748)
[INFO] ------------------------------------------------------------
------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------
------------
[INFO] Total time: 0.639 s
[INFO] Finished at: 2019-03-26T01:30:18+03:00
[INFO] Final Memory: 8M/106M
[INFO] ------------------------------------------------------------
------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-
plugin:1.2.1:java (default-cli) on project TicTacToe-Game: An
exception occured while executing the Java class.
com.mertilovski.app.Game -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven
with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug
logging.
[ERROR]
[ERROR] For more information about the errors and possible
solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Your XML structure seems incorrect as configuration node should be outside executions (docs):
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.mertilovski.app.Game</mainClass>
</configuration>
Firstly I declared a package com.mertilovski.app in top of my Game.java file.
Than I ran the
mvn exec:java -Dexec.mainClass="com.mertilovski.app.Game"
pom.xml looks like this (remaining part is same)
<configuration>
<mainClass>com.mertilovski.app.Game</mainClass>
</configuration>
When I run find . -type f -name "Game.class" I get :
./src/main/java/com/mertilovski/app/com/mertilovski/app/Game.class
./target/classes/com/mertilovski/app/Game.class
When I run my command, I get the following. Note that if I were to run the same thing from the command line ( with -D options ), it would work. So what I am doing wrong? -X and -e show me nothing of any value. I am currently researching if maybe my variables are not being picked up, but the url value is clearly defined, so while that might explain the missing/invalid file error, it would not explain the missing/invalid url error.
mvn deploy:deploy-file
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jooq-model 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy-file (default-cli) # jooq-model ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.280 s
[INFO] Finished at: 2018-10-23T20:24:49-04:00
[INFO] Final Memory: 6M/92M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project jooq-model: The parameters 'file', 'url' for goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
I am using the following configuration for the maven-deploy-plugin ( tell me if you need more ):
<build>
....
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>buildnumber</id>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<format>{0,number}</format>
<items>
<item>buildNumber</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-file</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
<url>file://home/tonyb/.m2/repository</url>
<sources>${project.build.directory}/${project.build.finalName}-sources.jar</sources>
<pomFile>pom.xml</pomFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}.${buildNumber}</finalName>
</build>
Regarding to The deploy:deploy-file Mojo, It told us as
The deploy:deploy-file mojo is used primarily for deploying artifacts
to which were not built by Maven.
Especially,
If the following required information is not specified in some way,
the goal will fail:
the artifact file to deploy
the group, artifact, version and packaging
of the file to deploy. These can be taken from the specified pomFile,
and overriden or specified using the command line. When the pomFile
contains a parent section, the parent's groupId can be considered if
the groupId is not specified further for the current project or on the
command line.
the repository information: the url to deploy to and the
repositoryId mapping to a server section in the settings.xml file. If
you don't specify a repositoryId, Maven will try to extract
authentication information using the id 'remote-repository'.
This means we have the built artifact e.g. our-artifact-1.0.jar and would like to deploy it to our repository. When execute the deploy:deploy-file, we have to pass those required parameters via the -D as the following example.
mvn deploy:deploy-file -Durl=file://C:\m2-repo \
-DrepositoryId=some.id \
-Dfile=our-artifact-1.0.jar \
Then if we would like to deploy our building artifact during the Maven Lifecycle, please use mvn deploy instead.
Given the below 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>
<groupId>com.myApp</groupId>
<artifactId>malloc</artifactId>
<version>0.0.1</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<repositories>
<repository>
<id>project</id>
<url>file:///${basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.myApp</groupId>
<artifactId>myApp.core</artifactId>
<version>1.0.0</version>
</dependency>
... //other dependencies
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<webResources>
<webResource>
<directory>${project.build.directory}/WebContent/WEB-INF</directory>
<includes>
<include>web.xml</include>
</includes>
<targetPath>WEB-INF</targetPath>
<filtering>true</filtering>
</webResource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/WebContent/WEB-INF/lib</outputDirectory>
<includeScope>runtime</includeScope>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And the following project structure:
I expect the maven-dependency-plugin would copy all the dependencies to the WebContent/WEB-INF/lib but when I run
mvn clean install
The following error is generated:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building api-malloc 0.0.1
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.oracle:ojdbc6:jar:10.2.0.4.0 is missing, no dependency information available
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # api-malloc ---
[INFO] Deleting C:\Development\malloc\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # api-malloc ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # api-malloc ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to C:\Development\malloc\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Development/malloc/src/com/myApp/api/malloc/dto/RegionTypeDTO.java:[3,34] package com.myApp.api.core.dto does not exist
[ERROR] /C:/Development/malloc/src/com/myApp/api/malloc/dto/RegionTypeDTO.java:[5,39] cannot find symbol
symbol: class IDTO
[INFO] 26 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.209 s
[INFO] Finished at: 2015-11-26T15:33:40-05:00
[INFO] Final Memory: 21M/227M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project malloc: Compilation failure: Compilation failure:
[ERROR] /C:/Development/malloc/src/com/myApp/api/malloc/dto/RegionTypeDTO.java:[3,34] package com.myApp.api.core.dto does not exist
[ERROR] /C:/Development/malloc/src/com/myApp/api/malloc/dto/RegionTypeDTO.java:[5,39] cannot find symbol
[ERROR] symbol: class IDTO
[ERROR] location: class com.myApp.api.malloc.controllers.TestController
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I noticed the WEB-INF/lib folder is always empty, maven dependencies are not copied over.
I am suspecting the copy-dependencies plugin didn't get run before the compile stage but I can't really figure out - anything that I missed?
The copy-dependencies goal indeed will never be executed if the compilation fails because its binding is to the package phase, which comes after the compile phase (to which by default is linked the Maven Compiler Plugin).
If you want it to run before the compile phase, you need to change the phase value of the execution of the copy-dependencies goal. Changing to process-resources should be fine and should also make sense.
<phase>package</phase>
For a full description of phases, you can check official documentation, here.
You should also fix the compilation errors the build output is pointing at. I see the sourceDirectory element is overriding what Maven uses by default for Java source code (src\main\java), hence I suppose your code is directly under the src folder.
Updated: the package X does not exist error occurs when the code is referring to a package not resolved by the Java compiler, hence it is not able to see that package in the classpath, which means in the declared dependencies: does myApp.core contain that package and class? If yes, then the repositories element (the lib folder) is probably not properly providing the myApp dependency.
You can try to install the dependency locally in your .m2 maven cache using the Maven Install Plugin as specified here.
You could execute from the command line as following:
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file
-Dfile=lib\myApp.core-1.0.0.jar \
-DgroupId=com.myApp \
-DartifactId=myApp.core \
-Dversion=1.0.0 \
-Dpackaging=jar \
Side note: Maven prefers lower case groupid and artifactid tokens. Moreover, instead of using Camel Case (i.e. myApp), Maven convention is also use a dash for separating tokens (i.e. myapp-core).
I'm using nar-maven-plugin with my spring boot project, everything goes well when developing but when i run maven package the project the compilation goes well until the final step where throws me the error:
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-test (default-nar-test) # customertracker ---
[INFO] Preparing Nar dependencies
[INFO] Unpacking 0 dependencies to /home/diego/Development/Web/Spring/CustomerTracker/target/test-nar
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-prepare-package (default-nar-prepare-package) # customertracker ---
[INFO]
[INFO] --- nar-maven-plugin:3.2.0:nar-package (default-nar-package) # customertracker ---
[INFO] Building zip: /home/diego/Development/Web/Spring/CustomerTracker/target/customertracker-0.0.1-SNAPSHOT-amd64-Linux-gpp-jni.nar
[INFO]
[INFO] --- maven-jar-plugin:2.5:jar (default-jar) # customertracker ---
[INFO] Building jar: /home/diego/Development/Web/Spring/CustomerTracker/target/customertracker-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.2.3.RELEASE:repackage (default) # customertracker ---
[INFO] Attaching archive: /home/diego/Development/Web/Spring/CustomerTracker/target/customer-tracker-app.nar, with classifier: null
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.190 s
[INFO] Finished at: 2015-05-20T09:41:16-05:00
[INFO] Final Memory: 32M/401M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage (default) on project customertracker: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage failed: For artifact {com.housingelectronics:customertracker:0.0.1-SNAPSHOT:nar}: An attached artifact must have a different ID than its corresponding main artifact. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
so i try to change the fileName property in spring-boot-maven-plugin and in my nar-maven-plugin output property, but not works
here is my maven simplified:
<?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.housingelectronics</groupId>
<artifactId>customertracker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>nar</packaging> <-- changing this to jar works but the applications does not find the .so library on runtime -->
<name>CustomerTracker</name>
<description>Customer Tracker</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>customertracker.CustomerTrackerApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<finalName>customer-tracker-app</finalName>
</configuration>
</plugin>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<output>customer-tracker-nar-generated</output>
<cpp>
<sourceDirectory>src/main/c++/udevLaserScannerDriverJNI/</sourceDirectory>
<includes>
<include>laserscannerlistener.cpp</include>
<include>utils.cpp</include>
<include>netlink/**/*.cc</include>
</includes>
</cpp>
<c>
<excludes>
<exclude>**/node_modules/**/*.c</exclude>
</excludes>
</c>
<java>
<include>true</include>
</java>
<javah>
<jniDirectory>src/main/c++/udevLaserScannerDriverJNI/</jniDirectory>
</javah>
<libraries>
<library>
<type>jni</type>
<narSystemPackage>customertracker.devices.udev</narSystemPackage>
</library>
</libraries>
</configuration>
<!-- <phase>generate-sources</phase> -->
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Thanks for any help.
i found the solution, what i do is to use classifier option instead of fileName in the spring-boot-maven-plugin and it works, this produces to me two nar files, one with the spring-boot application and the other with the .so library, now the problem is use them for run the application but this problem is independent of this thread.