Maven: compilation module fails - maven

I've these modules into my pom.xml:
<modules>
<module>rep-digital-common</module>
<module>rep-digital-api</module>
</modules>
So, rep-digital-common contains common classes rep-digital-api module needs.
When I compile them using
$ mvn clean compile
...
[INFO] rep-digital-common ................................. SUCCESS [ 7.571 s]
[INFO] rep-digital-api .................................... SUCCESS [ 17.988 s]
However, when I perform:
$ mvn -pl rep-digital-api clean package
it fails:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.345 s
[INFO] Finished at: 2018-08-28T12:29:19+02:00
[INFO] Final Memory: 58M/140M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project rep-digital-api: Compilation failure: Compilation failure:
[ERROR] /home/jcabre/projectes/repo-digital/rep-digital-api/src/main/java/net/gencat/transversal/repositori/digital/document/service/DocumentService.java:[29,65] cannot find symbol
[ERROR] symbol: class ContentStatus
ContentStatus symbol is located on rep-digital-common. I don't quite figure out what's going wrong.
Obviously, rep-digital-common is added as a rep-digital-api dependency:
<dependency>
<groupId>net.gencat.transversal.repositori.digital</groupId>
<artifactId>rep-digital-common</artifactId>
</dependency>
Any ideas?

Executing mvn clean compile or mvn clean package don't add the built artifacts in the local repository.
To add built artifacts in the local repository you have to use mvn clean install.
Note that as actually you build a reactor project, it works because the reactor provides dependencies needed to each current module to build.
On the other hand, as you compile rep-digital-api alone, the reactor will not help you :
mvn -pl rep-digital-api clean package
and so the compilation can only fail as rep-digital-common classes are not resolvable.

Related

Building Gluon Apps in Multi-Module Project

TL;DR: How does one build a Gluon app that's part of a larger multi-module project?
I have a multi-module Mave project (that is, my top-level POM has "<packaging>pom</packaging>"). The project contains a bunch of libraries and related sub-projects, one of which is a Gluon app that will be what my actual users install. (The rest of the project is all the cloud-hosted plumbing that the client app connects to.)
When I try to build the Gluon app, per the Gluon documentation, I am getting the following error:
mvn gluonfx:build
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] app [pom]
[INFO] app-common [jar]
[INFO] app-server [jar]
[INFO] app-client [jar]
[INFO] app-test [jar]
[INFO] app-utilities [jar]
[INFO] app-integration-lambda [jar]
[INFO] app-integration-jakarta [war]
[INFO] app-gluon [jar]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for app 0.9:
[INFO]
[INFO] app ............................................ SKIPPED
[INFO] app-common ..................................... SKIPPED
[INFO] app-server ..................................... SKIPPED
[INFO] app-client ..................................... SKIPPED
[INFO] app-test ....................................... SKIPPED
[INFO] app-utilities .................................. SKIPPED
[INFO] app-integration-lambda ......................... SKIPPED
[INFO] app-integration-jakarta ........................ SKIPPED
[INFO] app-gluon ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.298 s
[INFO] Finished at: 2022-02-22T21:03:18+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'gluonfx' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Administrator\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException
If I run Maven so that it only builds the Gluon application instead, like this:
mvn gluonfx:build --projects "app-gluon" --also-make
I get basically the same error. If I cd to app-gluon first, I get a different error (and I didn't expect this to work anyhow):
cd app-gluon
mvn gluonfx:build
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.whatever:app-gluon >--------------------
[INFO] Building app-gluon 0.9
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.whatever:app-common:jar:0.9 is missing, no dependency information available
[WARNING] The POM for com.whatever:app-client:jar:0.9 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.380 s
[INFO] Finished at: 2022-02-22T21:09:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project app-gluon: Could not resolve dependencies for project com.whatever:app-gluon:jar:0.9: The following artifacts could not be
resolved: com.whatever:app-common:jar:0.9, com.whatever:app-client:jar:0.9: com.whatever:app-common:jar:0.9 was not found in https://nexus.gluonhq.com/nexus/
content/repositories/releases during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of Gluon has elapsed or updates are forced -> [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/DependencyResolutionException
So my question is: how does one build a Gluon app that's part of a larger multi-module project?
If you have a multi module project, and your app module depends on other modules, you need to publish those modules to a repository, so the app module finds them, like any other third party dependency.
Typically, for local development, you can simply use mvn install from the root folder to deploy your project locally. Of course, for distribution, you should consider publishing them to a reachable repository.
Make sure all your modules are deployed to your ~/.m2 repository.
Then you can run from the root:
mvn gluonfx:build -f app-gluon
or enter in the app-gluon folder:
cd app-gluon
mvn gluonfx:build
And remember that every time you make any change to the other modules, you will need to publish them again before building the native image.
Also, since you can run your app on the JVM, before building the native image (which takes a couple of minutes), you can simply run and test:
mvn gluonfx:run
and if that works fine, do the native image build.

Maven: local dependency installed not found

This is my project structure:
$ ls
pom.xml
README.md
rep-digital-api
rep-digital-common
So, rep-digital-api has rep-digital-common as dependency.
I first install succesfully rep-digital-common:
mvn -pl rep-digital-common clean package install
The problem appears when I'm trying to tun my rep-digital-api spring-boot service:
mvn clean package -pl rep-digital-api
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building rep-digital-api 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.417 s
[INFO] Finished at: 2018-08-13T15:35:28+02:00
[INFO] Final Memory: 28M/68M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project rep-digital-api: Could not resolve dependencies for project net.gencat.transversal.repositori.digital:rep-digital-api:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at net.gencat.transversal.repositori.digital:rep-digital-common:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for net.gencat.transversal.repositori.digital:rep-digital-common:jar:0.0.1-SNAPSHOT: Could not find artifact net.gencat.transversal.repositori.digital:rep-digital:pom:0.0.1-SNAPSHOT -> [Help 1]
EDIT
Parent pom.xml fragment:
<modules>
<module>rep-digital-common</module>
<module>rep-digital-api</module>
</modules>
I've took a look on my local repositori. The package seems to be installed:
$ ls ~/.m2/repository/net/gencat/transversal/repositori/digital/rep-digital-common/
0.0.1-SNAPSHOT maven-metadata-local.xml
My ~/.m2/settings.xml fragment:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
</settings>
EDIT 2
Parent pom.xml is:
<groupId>net.gencat.transversal.repositori.digital</groupId>
<artifactId>rep-digital</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
I've realized mvn is telling me that parent's pom.xml can't be resolved:
Could not find artifact net.gencat.transversal.repositori.digital:rep-digital:pom:0.0.1-SNAPSHOT

Applying a patch at runtime in Maven

I'm trying to install Giraph 1.1 but ran into an issue. According to this thread I should apply a patch to my installation. Unfortunately, my problem stems from that. I downloaded and copied the .patch file linked in there to the source folder and added the following to the pom.xml:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-patch-plugin</artifactId>
<version>1.2</version>
<configuration>
<patches>
<patch>GIRAPH-1110.02.patch</patch>
</patches>
...
</plugins>
Unfortunately when I run Maven with:
sudo mvn -Phadoop_yarn -Dhadoop.version=2.8.1 clean package -DskipTests
it still fails with the same error as it did before:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /usr/local/giraph/giraph-core/target/munged/main/org/apache/giraph/job/GiraphJob.java:[213,11] setPingInterval(org.apache.hadoop.conf.Configuration,int) is not public in org.apache.hadoop.ipc.Client; cannot be accessed from outside package
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Apache Giraph Parent ............................... SUCCESS [ 6.298 s]
[INFO] Apache Giraph Core ................................. FAILURE [ 9.359 s]
[INFO] Apache Giraph Examples ............................. SKIPPED
[INFO] Apache Giraph Distribution ......................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.062 s
[INFO] Finished at: 2018-02-06T22:53:00+02:00
[INFO] Final Memory: 51M/640M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project giraph-core: Compilation failure
[ERROR] /usr/local/giraph/giraph-core/target/munged/main/org/apache/giraph/job/GiraphJob.java:[213,11] setPingInterval(org.apache.hadoop.conf.Configuration,int) is not public in org.apache.hadoop.ipc.Client; cannot be accessed from outside package
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
which clearly shows that the issue has not been patched. When I check the file manually, I can confirm that there's no change. If I change the file manually before compilation, the changes get discarded (I'm guessing the file gets redownloaded). Also can't run the installation with offline flag since it depends on downloading some dependencies. I'm at my wits end here.
My Maven version is 3.3.9.

Maven - Reactors (Aggregation)

I have a maven project with a following directory structure:
trunk
| pom.xml
| coreutils
| | pom.xml
| | src
| budgetCap
| | pom.xml
| | src
The content of trunk/pom.xml is :
<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
hxttp://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Ant2Maven</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>Parent Pom</name>
<modules>
<module>coreutils</module>
<module>budgetCap</module>
</modules>
In this structure, "budgetCap" is dependent on "coreutils",i.e. pom.xml of "budgetCap" contains a dependency of "coreutils"
Now I have two methods to build this project
First Method
Aggregation using Reactor
I will be inside trunk
So first of all I do mvn clean
shakim:trunk shakim.md$ mvn clean
Maven deletes the target folder of the two module in this order:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] coreutils
[INFO] budgetCap Maven Webapp
[INFO] Parent Pom
Now when i do mvn install
shakim:trunk shakim.md$ mvn install
Maven starts building modules in the following order:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] coreutils
[INFO] budgetCap Maven Webapp
[INFO] Parent Pom
In the given order, coreutils gets installed in the local repository successfully.
But budgetCap fails at the compilation giving an error that maven is unable to locate a class which was supposed to be produced by coreutils
the error message is as follows:
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building budgetCap Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # budgetCap ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # budgetCap ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 65 source files to /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING]/Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/SingletonAggregator.java: /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/SingletonAggregator.java uses unchecked or unsafe operations.
[WARNING]/Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/SingletonAggregator.java: Recompile with -Xlint:unchecked for details.
[INFO] 2 warnings
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/core/BudgetCapServer.java:[41,34] package com.adiquity.request.utils does not exist
[ERROR] /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/utils/Utils.java:[9,34] package com.adiquity.request.utils does not exist
[ERROR] /Users/shakim.md/shakim/maven/ops/adq_services/trunk/budgetCap/src/main/java/com/adiquity/budgetCap/log/data/parser/ConversionParser.java:[16,34] package com.adiquity.request.utils does not exist
Briefly speaking this package package com.adiquity.request.utils is actually present in coreutils, which this module budgetCap must have located successfully, but it is not.
Second Method
Go inside coreutils and do a
shakim:coreutils shakim.md$ mvn clean install
Go inside budgetCap and do a
shakim:budgetCap shakim.md$ mvn clean install
budgetCap compiles successfully without reporting any kind of error.
My question is that I want to use Reactors in Maven and I am unable to figure out why the build fails on using 1st method whereas 2nd method of building completes smoothly??
I am not sure how to use reactors, do we need to include anything in pom of coreutils and budgetCap signifying that pom of trunk is the parent.
Note: I don't want to use inheritance in this project

Jenkins: custom jar dependency issue

I'm creating a jar through a project and copied the jar to c:\mylib\test-automation-library-0.0.1-SNAPSHOT.jar
<groupId>com.mycompany.taf</groupId>
<artifactId>test-automation-library</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test Automation Library</name>
<description>Test Automation Library</description>
<url>http://maven.apache.org</url>
Now, I'm running the test scripts through Jenkins.In the Jenkins job of test scripts, I included the following pre-build step install the library:
install:install-file
-Dfile=c:\mylib\test-automation-library-0.0.1-SNAPSHOT.jar
-DgroupId=com.mycompany.taf
-DartifactId=test-automation-library
-Dversion=0.0.1
-Dpackaging=jar
This installs the jar to maven local repository (where are the scripts are supposed to run) and build is successful in the POM file of the test-scripts, I included the following dependency for the above library:
<dependency>
<groupId>com.mycompany.taf</groupId>
<artifactId>test-automation-library</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
If I do maven install (of the test-scripts project) through Jenkins, I'm hitting the following error:
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.mycompany.taf:test-automation-library:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Is it something wrong with the dependency? I tried the with all different options and also googled it, but was not able to figured out what the problem was. I'm really blocked here. any help/pointers are greatly appreciated.
Thanks in advance.
Rams.
Rams,
Your command reads:
install:install-file
-Dfile=c:\mylib\test-automation-library-0.0.1-SNAPSHOT.jar
-DgroupId=com.mycompany.taf
-DartifactId=test-automation-library
-Dversion=0.0.1
-Dpackaging=jar
Your version number is missing the -SNAPSHOT qualifier.
Hope that helps.
#333kenshin, this is continuation to my previous comment to your question.
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # test-automation-library ---
[INFO] Installing C:\Program Files (x86)\Jenkins\workspace\AmzonPOCTest1\test-automation- library\target\test-automation-library-0.0.1-SNAPSHOT.jar to C:\Windows\system32\config\systemprofile\.m2\repository\com\mycompany\taf\test-automation-library\0.0.1-SNAPSHOT\test-automation-library-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.938 s
[INFO] Finished at: 2014-10-23T03:38:39-07:00`enter code here`
[INFO] Final Memory: 23M/122M
[INFO] ------------------------------------------------------------------------ enter code here
FYI: I logged into my windows PC non-admin user. I believe it does not matter.

Resources