closure compiler maven plugin build failed multi-module project - maven

I have this project: https://github.com/gdesouzacrispim/closure-compiler-minify using closure compiler maven plugin (https://github.com/blutorange/closure-compiler-maven-plugin) where exist a module parent and children;
The plugin is declared in parent pom but it dont have directory path configured int tag baseSourceDir but the children have
Is there any configuration that will ignore when the files isnt existent to be minified in parent module?
[ERROR] Failed to execute goal com.github.blutorange:closure-compiler-maven-plugin:2.22.0:minify (default-minify) on project parent: Execution default-minify of goal com.github.blutorange:closure-compiler-maven-plugin:2.22.0:minify failed: basedir /home/myuser/dev/closure-compile/parent/src/main/webapp/resources does not exist -> [Help 1]

Related

Maven Build Compilation Error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:analyze-dep-mgt

I have a multi-module Maven project in one root project I just want to add another maven module in the root project which contains many module, so after calling the parent from the pom.xml child I get the following error:
parent pom:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:analyze-dep-mgt (default) on project calender: Found Dependency errors.
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:analyze-dep
-mgt (default) on project calender: Found Dependency errors.
analyze-dep-mgt is a mojo which detects whenever there are dependency mismatches during the final resolution of the build. (https://maven.apache.org/plugins/maven-dependency-plugin/analyze-dep-mgt-mojo.html)
There is likely to be a problem with your dependencies. Check this documentation for more info on how to structure your poms. (https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html)
I recently had this error when adding a new dependency in which a transitive dependency was causing the same goal fail. Using an older version of the dependency resolved the issue.

maven-compiler-plugin compile project with jar library

I have a maven project, which has a library (hello1.jar), that I add with IDEA. In this jar file I have the class ru.training.Hello1. In project I have the class Hello2, which contains field Hello1 hello1. When I try to compile the project with maven lifecycle, I get an error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project Learning: Compilation failure: Compilation failure:
[ERROR] /C:/Projects/Learning/src/main/java/reflection/Hello2.java:[3,19] package ru.training does not exist
[ERROR] /C:/Projects/Learning/src/main/java/reflection/Hello2.java:[7,13] cannot find symbol
[ERROR] symbol: class Hello1
What can I do to fix this error?
In this case you need to add local jar file to local repository and then compile the project. How to add local jar I have read here: How to add local jar files to a Maven project?

Can I use a custom lifecycle defined in a multi-module project?

I have a project that has a complex lifecycle, so a custom lifecycle makes sense. However, I would like to be able to have the lifecycle defined in a plugin that is in the same multi-module build. The plugin just defines the custom lifecycle (in a components.xml).
apollo-server-parent
- apollo-server-lifecycle-plugin
- src/main/resources/META-INF/plexus/components.xml (defines apollo-server-product)
- ApolloServer
- pom.xml
...
<packaging>apollo-server-product</packaging>
...
<plugin>
<groupId>ca.nanometrics.apollo</groupId>
<artifactId>apollo-server-lifecycle-plugin</artifactId>
<version>${project.parent.version}</version>
<extensions>true</extensions>
</plugin>
However, if I do this, maven won't build because it cannot find the apollo-server-lifecycle-plugin because it has not been built yet while building the reactor. Any ideas on how to work around this? Do I have to define the plugin in a separate project?
An example of the error I get:
[ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin ca.nanometrics.apollo:apollo-server-plugin:4.0.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact ca.nanometrics.apollo:apollo-server-plugin:jar:4.0.0-SNAPSHOT in releases (http://.../nexus/content/groups/public) #
[ERROR] Unknown packaging: apollo-server-product # ca.nanometrics.apollo:ApolloServer:[unknown-version], /opt/atlassian/pipelines/agent/build/ApolloServer/pom.xml, line 10, column 14
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project ca.nanometrics.apollo:ApolloServer:4.0.0-SNAPSHOT (/opt/atlassian/pipelines/agent/build/ApolloServer/pom.xml) has 2 errors
[ERROR] Unresolveable build extension: Plugin ca.nanometrics.apollo:apollo-server-plugin:4.0.0-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact ca.nanometrics.apollo:apollo-server-plugin:jar:4.0.0-SNAPSHOT in releases (http://.../nexus/content/groups/public) -> [Help 2]
[ERROR] Unknown packaging: apollo-server-product # ca.nanometrics.apollo:ApolloServer:[unknown-version], /opt/atlassian/pipelines/agent/build/ApolloServer/pom.xml, line 10, column 14
If I am not getting you wrong here -
You want to build ApolloServer module, which uses
apollo-server-lifecycle-plugin which is also a module of your
project.
Current project structure being :
apollo-server-parent
- apollo-server-lifecycle-plugin
- ApolloServer
From the multi-module guide, one simple way of doing this could be making sure that apollo-server-lifecycle-plugin is build prior to the ApolloServer module always. Easiest way to do that could be to include the dependency of apollo-server-lifecycle-plugin in ApolloServer(pom.xml) which would make sure the Reactor sorting builds plugin first.
a plugin dependency on another module in the build

Execute maven assembly plugin only on child POMs

I have a project with a parent POM and three child projects with.I want to execute the goal assembly:assembly only on one child POM. I already read the following post, but I didn't get it to work with the maven assembly plugin.
Execute Maven plugin goal on child modules, but not on parent
If I run
mvn -DskipTests=true assembly:assembly
I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:assembly (default-cli) on project inhouse: Error reading assemblies: No assembly descriptors found. -> [Help 1]
It seems that it always parses the plugin configuration and looks for the assembly descriptor, even then, if I do not put the plugin into the parent POM at all. Has anyone a solution for the assembly plugin?
the rigth option is : <skipAssembly>true</skipAssembly> in order to skip the parent project.
you can define in parent pom properties
<assembly.skipAssembly>true</assembly.skipAssembly>
and overwritte this property in your module pom properties
<assembly.skipAssembly>false</assembly.skipAssembly>
You can configure in the aggregation pom.xml the assembly plugin to skip execution.
In <build><plugins> section
<configuration><skip>true</skip></configuration>

m2eclipse: Multi-module and parent build exception

I am new to m2eclipse, and I created a dummy java project (mytest4) and checked enable dependency management, after that, the plugin created a pom.xml file. I manually added parent information, such as groupId, artifactId and version, etc. to the dummy project. Then I added modules to the parent project, and the parent projectType is pom not jar. However, when I build using clean install, I get an error:
[DEBUG] Extension realms for project com.multimod:myproject:pom:0.0.1-SNAPSHOT: (none)
[DEBUG] Looking up lifecyle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[ERROR] The build could not read 1 project ->
[Help 1]org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] Child module C:\workspace\myproject\mytest4 of C:\workspace\myproject\pom.xml does not exist #
[ERROR] The project com.multimod:myproject:0.0.1-SNAPSHOT(C:\workspace\myproject\pom.xml) has 1 error
[ERROR] Child module C:\workspace\myproject\mytest4 of C:\workspace\myproject\pom.xml does not exist
I don't understand C:\workspance\myproject\pom.xml does not exist.
Could you give some hints?
Thank you.
You probably have to set the relative path to you parent pom file in the mytest4 pom file. The default is ../pom.xml hence your path C:\workspace\myproject\pom.xml.
As to your sub question in the comment. Right click on the project en select Configure > Convert to Maven Project

Resources