Install fails in maven, but succeeds in IntelliJ directly - maven

I have a project with many modules that compiles fine in intellij.
When I try to build it in maven (via clean install) I get "COMPILATION ERROR : " and many problems on a specific module, that on IntelliJ are just fine.
I tried restarting Intellij (and cleaned the caches), I tried to uninstall it and reinstall it, tried to uncheck and check reimport automatically, tried reimporitng all the projects, and building and installing them all (and succeeded), updating the repository path, tried to install new maven (3.6 instead of 3.3), and even tried to run maven via the terminal - all that didn't help.
EDIT: I even tried cleaning maven's cache like in here, but failed.
Maven clean succeeds.
I use mac.
So basically my project works, maven doesn't. What could be the problem?

The problem was that the project I included was a spring boot project, and that made maven confused (but unfortunately, IntelliJ was ok with it).
Adding this fixed the problem:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>

Related

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin: 3.0.0-M4 (default-test). There are test failures- JENKINS

I did download the project from github without any problem, i provided th maven commands mvn clean install and the project build successfully but when it comes to run the tests i get the following error. Any hints? I'am providing my pom.xml file, i tried all the suggestions but nothing.
Does your pom.xml contains the plugin surefire tag ? If thats missing then maven wont download this plugin at runtime and hence the error. Also if its there but maven cant download then may be you have to allow internet connectivity or copy the jars manually inside the .m2 directory on the Jenkins/Node server machine.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
</plugin>

Unable to create maven package for AEM due to use of data-sly-set

When attempting to create a package for my ui.apps folder with maven I receive this error
data-sly-set: None of the registered plugins can handle the
data-sly-set block element.
I am indeed using the data-sly-set property like so
<sly data-sly-set.index="${mylist.count}"></sly>
And it does work on my local instance it just fails validation when packaging it.
I noticed that htl-maven-plugin was on version 1.0.6 if that is related.
The issue was that the version of htl-maven-plugin was too old. I resolved this issue by going into pom.xml and added
<version>1.3.4-1.4.0</version>
underneath
<artifactId>htl-maven-plugin</artifactId>
It ended up looking like this
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>htl-maven-plugin</artifactId>
<version>1.3.4-1.4.0</version>
</plugin>
After that it I ran
mvn -PautoInstallPackage clean install
and it built successfully. I also ran
mvn versions:display-plugin-updates
earlier to force it to update but I'm not entirely sure if that was necessary.

Maven Compile Access Denied Copying Dependencies

I have a weird problem with Maven that I've not run into before. I appear to be the only one having the problem on my team and this is for a project that has existed for a significant period of time (10+ years). I'm new to the team, but so are other members who do not seem to be having this problem.
Here's the problem:
If I do a mvn clean compile, I get the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:dependency-maven-plugin:1.0:copy (copy-dependencies)
on project deployable-war: Error copying artifact
from C:\...\dependency\target\classes
to C:\...\deployable-war\target\dependency\jws\lib\classes:
C:\...\dependency\target\classes (Access is denied) -> [Help 1]
Now, the weird part is that source and destination folders (dependency\target\classes and deployable-war\target\dependency\jws\lib\classes) were both created by Maven during the same compile command. This is a multi-module project, so mvn compile will go through all 9 modules. This is module 8. The dependency module is module 7.
If I re-run mvn compile (without the clean) afterwards, it gives the same error, so it does not seem to be a timing issue.
If I manually create the folder (mkdir ...\deployable-war\target\dependency\jws\lib\classes) and re-run mvn compile, everything works fine. That includes it copying JAR files inside of the lib folder that it said was access denied when it tried to create the classes folder.
I've tried deleting the \target\ folder entirely.
I've tried running Maven as an administrator.
I've tried checking out a new copy of the project from Git into a new directory on my local.
I've checked folder permissions on the project itself to ensure that my user and the administrator user have full control.
OS is Windows 10 Enterprise.
Any suggestions?
EDIT: From discussion, tracked the error down to this part of the pom.xml for the module:
<build>
<finalName>deployable</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dependency-maven-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>compile</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/jws/lib</outputDirectory>
<artifactItems>
<artifactItem>
Now, the issue appears to be related to a subset of the artifactItem - particular, artifactItems that do not have explicitly-defined destFileNames.
Long time coming back to this, but Gerold's comment lead me to the right resolution. The problem was the copy-dependencies happens after package. So the problem was that I was mvn clean compile, when I needed to be mvn clean package
I limped along taking way too long to sort that out. The fun of multi-module, interdependent projects

Wro4j maven plugin - required class is missing

I'm trying to run wro4j maven plugin according to the documentation
I add the plugin to my pom.xml:
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>1.5.0</version>
</plugin>
and run the goal:
mvn wro4j:run -Dminimize=true -DtargetGroups=all
However the build fails with error:
org.apache.maven.lifecycle.LifecycleExecutionException: Internal error in the pl
ugin manager executing goal 'ro.isdc.wro4j:wro4j-maven-plugin:1.5.0:run': Unable
to load the mojo 'ro.isdc.wro4j:wro4j-maven-plugin:1.5.0:run' in the plugin 'ro
.isdc.wro4j:wro4j-maven-plugin'. A required class is missing: org/codehaus/plexu
s/util/Scanner
Do you know how to avoid this error?
Since wro4j-1.5.0, the maven 3.0 is required to run the plugin. The reason is a feature called incremental build support which depends on a library which is not available on older version of maven by default.
The issue is on your local environment.
Go to this folder on my windows machine:${user.home}/.m2/repository, then delete everything in this folder. (Well you can keep a copy.)
After deleting, run the Maven command:mvn clean install -U.
See: https://groups.google.com/forum/#!topic/wro4j/ZPSFBQ_5lI8

How to make M2E eclipse plugin understand Bundle packaging

I'm almost new with Osgi.
I'm using Eclipse 3.6 Helios for building my first Felix Bundle but find out that M2E don't understand bundle packaging...
Project build error: Unknown packaging: bundle
Project build error: Unresolveable build extension:
Plugin org.apache.felix:maven-bundle-plugin:2.0.0 or one of its dependencies could not be resolved:
Failed to collect dependencies for org.apache.felix:maven-bundle-plugin:jar:2.0.0 ()
As I done google searches, it was an error in Maven 2 but fixed in Maven 3 with M2E using.
Also, I'm using Window XP and under a proxy, which I think I sussefully config it, other connections in Eclipse work fine...
So I don't know how to get M2E understand bundle packaging ?
Using these settings, import the maven project. If there are missing connectors (which links maven goals and eclipse plugins), the 'Next' button should be enabled. Do Next and auto-resolve the connectors to install tycho plugins. From now on, your project will have a Plugin nature.
P.S Be sure to at least have one class to compile in the project or maven-bundle-plugin will complain.
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
</plugin>
</plugins>
Justy FYI, ebelanger's answer above led me down the right direction. If you're not seeing the eclipse popup prompting for resolving connections, you need to add the parent pom that declares the plugin to eclipse.
In my case I had a child pom project I was importing into eclipse (but not the parent pom). Note that the actual plugin decleragion for maven-bundle-plugin was in the parent pom, not the child pom eclipse was aware of.
With just the child imported, Eclipse's build problems panel showed the errors about not being able to find the maven-bundle-plugin dependency, but the "quick fix" option after right clicking on the error in the problems panel was greyed out.
Importing the parent project into eclipse caused it to pop up the prompt asking for eclipse plugin connectors to install to support the maven-bundle-plugin.

Resources