Unresolved plugin: 'org.apache.maven.plugins:maven-jar-plugin:2.4' - maven

After I use IntelliJ IDEA to create a maven module, there is some problem in the Maven Projects view. And when my cursor hover on the maven project, i see this:
Project:
cn.itcast.babasport:parent:1.0-SNAPSHOT
Location:
/home/shuaidi/IdeaProjects/parent/pom.xml
Problems:
Unresolved plugin: 'org.apache.maven.plugins:maven-jar-plugin:2.4'
Unresolved plugin: 'org.apache.maven.plugins:maven-compiler-plugin:3.1'
Unresolved plugin: 'org.apache.maven.plugins:maven-surefire-plugin:2.12.4'
Unresolved plugin: 'org.apache.maven.plugins:maven-install-plugin:2.4'
Unresolved plugin: 'org.apache.maven.plugins:maven-site-plugin:3.3'
This is my first time using IntelliJ IDEA, so I do these thing with a new installed IDEA and a new installed maven, and i just create a maven module and didn't do any other thing. I don't know why these problem appearance.
I just want to create a maven module without any problem.
ps:
this is all my pom file.
<?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>cn.itcast.babasport</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</project>

This is a duplicate of Maven plugins can not be found in IntelliJ. The top answers there did not work for me, so I'll describe what I did.
I just put the needed plugins into my ~/.m2/repository. There are two ways that achieve that. Either download the files manually with mvn dependency:get, or (my preferred way) make the plugins a dependency in some (whichever) pom.xml and build that project.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<type>maven-plugin</type>
</dependency>
Now you can remove the dependencies. Then click "Reimport all Maven Projects" in Intellij (the blue circular arrows icon).
This issue seems completely harmless, but the squiggly lines are kind of infuriating, so I am glad I was able to get rid of them.

Instead of trying to install the plugin into your repository, actually delete it from your repository. It might have a corrupt or unsupported version that IJ cannot parse.
see https://stackoverflow.com/a/44883900/5093961

Change Maven home directory in Maven setting, and select supported Maven bundle version (Maven 2 or Maven 3), then apply setting. It's worked for me.

In my case same situation occurred because of different version exist in same system.
System have version 2.** and my project expect 3.** something
in such case, i use maven wrapper instead of maven to build project.
mvn clean install
instead of,
mvnw clean install

If you want this error to be gone without having to worry about all those xml files and copy pasting stuff just try the below solution
Note: This is manual way
In your InteliJ IDEA, go to search and type "Project Structure"
Search>Project Structure
or press:
Ctrl + Alt + Shift + S
Now go to Libraries under project settings
Project Settings>Libraries
Now look for red lined dependencies and click it
For example:
Click "Maven: javax:javaee-web-api:7.0"
Now look whether all three files are red lined
Example: Classes, Sources, JavaDocs
If any of the path under these names are redlined then go to that path and keep the folder open
For example: The path would look like this
Classes
C:\Users\shifny.m2\repository\javax\javaee-web-api\7.0\javaee-web-api-7.0.jar
Sources
C:\Users\shifny.m2\repository\javax\javaee-web-api\7.0\javaee-web-api-7.0-sources.jar
JavaDocs
C:\Users\shifny.m2\repository\javax\javaee-web-api\7.0\javaee-web-api-7.0-javadoc.jar
Now go to the folder as said above and keep it open
In my case its
C:\Users\shifny.m2\repository\javax\javaee-web-api\7.0
Now click this website
and search for the jar file
In my case it's:
javaee web api
Now click the link and select the version in next page
In my case it's:
7.0
Now find the "Files" row which will be between "Date" and "Repositories"
In the Files row, click View All
It will open a page like This
In that page download the missing files(classes,source,javadoc)
It will look like this
javaee-web-api-7.0.jar
javaee-web-api-7.0-sources.jar
javaee-web-api-7.0-javadoc.jar
Download all three and put it into the folder which I said you to keep open
Now open your project in inteliJ IDEA and build your project and open the "project structure" as instructed above and check it, the redlined files will have no redlines anymore.
This may seem easy but if there are more files which generates errors then you will have to do this process multiple times and download the missing files.
In that case the above solutions may help...

Check idea.log for errors related to Maven importing, it could be
a network issue with localhost
invalid VM options for Maven VM (too large heap or a typo in VM options)
Maven process failing for some other reason (like the recent Nvidia driver update has caused Java crashes).

I just solved this problem few minutes ago and this is what I figured and my solution:
The reason intellij is popping up with those errors is because the plugin files for those failed plugins in the ".m2" directory are not properly downloaded or they are broken.
This is what I did:
I went to "C:\Users\IYANU.m2\repository\org\apache\maven\plugins" folder. You will see that the name of the plugins matches the ones giving errors in IntelliJ
One after the other, in each plugin folder, I checked for the version giving error in IntelliJ then delete the version folder. Like for "maven-jar-plugin", the version in 2.4, delete the 2.4 folder in the maven-jar-plugin folder.
After deleting, go back to IntelliJ and reload your maven project. Make sure there is an internet connection. This will make IntelliJ properly download the plugin and the error won't pop up for that particular plugin again.
Repeat it for the other plugins giving error
Thank me later

This worked for me:
Download 'maven-jar-plugin:2.4.jar' from maven-repository (https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin/2.4)
Paste the downloaded 'maven-jar-plugin:2.4.jar' in the local PC's mvn-repository ('C:\Users\[user-name].m2\repository\org\apache\maven\plugins\maven-jar-plugin\2.4' folder)
Wait for IntelliJ to pick up the change
All done!

Related

Proper way to add ojdbc8.jar to Eclipse/maven project

Just joined a company (and an existing project) and first blocker is getting Eclipse/maven/pom.xml to recognize I do actually have the ojdbc8.jar file on my system. Eclipse/maven/pom.xml disagree. When looking at the pom.xml file, Eclipse says "Missing artifact com.oracle.jdbc:ojdbc8:jar:12.2.0.1"
I have tried adding the jar to the "Referenced Libraries". No joy.
I have tried installing maven and then the jar into the maven repo (see this link) which ran fine, but Eclipse/maven still say the artifact is missing.
I guess because Eclipse uses it's own maven repo, but I don't know how to add a jar file to it, or if that is even the right way to do this. ** After reading some more, it appears I have been misled and Eclipse does not have it's own maven repo?**
I also found this at Oracle's website, but it seems like a lot of steps and I already added the jar to my local repo so I don't expect it to help.
I have tried asking my co-worker. No response...
Anyone know how to do this?
So I found this page
which is completely different from anything else I have read (so far). You add the Oracle jdbc file to your Eclipse preferences. Nothing to do with your project. My pom.xml file is not longer red.
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>

Intellij Spring maven install error "package does not exist"

Intellij version : Community 2019.2.3
Maven : 3.6.2
Spring : 2.2.0
I am trying to create a very simple Spring maven project with two sub-modules (one independent and another one dependent on independent one).
Root module - testmultimodule
Independent module - independent
Dependent module - dependent
testmultimodule pom.xml has all Spring related declaration and module definition
<modules>
<module>independent</module>
<module>dependant</module>
</modules>
Independent poom.xml is simplest and . only has parent maven declaration
<parent>
<artifactId>testmultimodule</artifactId>
<groupId>in.org.app</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
dependent module pom.xml has the dependency declaration as below to independent module
<dependencies>
<dependency>
<groupId>in.org.app</groupId>
<artifactId>independent</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
I have created a Test class under dependent module and using a User object from independent module. Initially, without the above dependency declaration, asa usual there was compilcation error.
As soon as I add the dependency and builld the project within Intellij IDE with the option "Build Prooject" option from "Build" menu, it successfully builds.
However, if I try to use Maven install option within Intellij right side window option. It always fails stating Error:(3,33) java: package in.org.app.independent.bo does not exist .
I am providing the GitHub URL for the test project , if you want to take a look and test by yourself.
GIT URL:
https://github.com/DhruboB/testmultimodule
I have tried all sort of tweaking found in internet so far e.g.
clearing Intellij Cache & restarting, mvn -U clean install, mvn scope verification, proxy etc.
Any further idea to resolve this? I need to solve this in the Community version of Intellij.
Your parent project includes the definition for the spring-boot-maven-plugin. This leads to each project defining this as a parent to be repacked to an executable JAR by this plugin. This repackaged JAR isn't useable as a dependency in another project.
Either you need to change the configuration of the spring-boot-maven-plugin for the project you want to use as a dependency. This is explained here in the Spring Boot Reference Guide. You now basically have 2 jars from this project, one plain and one executable.
If you don't need that project to be an executable JAR file then just move the spring-boot-maven-plugin to the project that needs to be. All other projects will no be basic JAR files again.
See also How to add a dependency to a Spring Boot Jar in another project?

Alfresco SK3 - JAR AIO Project dependencies

In the < SDK3 AMP projects, there was the ability to install-amps in the POM.xml when running from Eclipse. This would allow for an existing AMP(s) project to be applied when running/debugging from Eclipse.
As we are changing our projects to JAR AllInOne projects, I'm wondering what the actual process is to duplicate this? "Project2" fails to run (mvn clean install alfresco:run) as our "Project2" JARs are dependent on models in the "Project1" Jars.
I thought the overlays section might do this but the model defined in "Project1" is not found when running "Project2" via maven.
Previously when using the AMPs the install-AMPs section of the pom.xml would make sure that the dependencies webscripts/models were available at runtime. Is there a way to mimic this with two AIO Jar projects?
AIO projects with Alfresco SDK 3.0 can pull in other AMPs without a problem.
Make sure that you've uncommented the part of the pom.xml that actually builds an AMP. Look for the section that starts like this:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>build-amp-file</id>
And make sure it is uncommented.
Once you've done that, you can add AMPs as both platform-tier dependencies and Share-tier dependencies. For a platform-tier dependency, look for the "" element and add your dependencies there, making sure to specify that the type is "amp".
For a Share-tier dependency look for "".
For example, I often like to install the JavaScript Console in my AIO projects because it is so handy. So, I add the following to platformModules:
<!-- JavaScript Console -->
<moduleDependency>
<groupId>de.fmaul</groupId>
<artifactId>javascript-console-repo</artifactId>
<type>amp</type>
<version>0.7-SNAPSHOT</version>
</moduleDependency>
And I add the following to :
<!-- JavaScript Console -->
<moduleDependency>
<groupId>de.fmaul</groupId>
<artifactId>javascript-console-share</artifactId>
<type>amp</type>
<version>0.7-SNAPSHOT</version>
</moduleDependency>
With those in place, when I run my AIO project using run.sh, Tomcat starts up, the JavaScript Console AMPs are installed, and my customizations are installed.

How to avoid "The package is not exported by the bundle dependencies" error in IntelliJ IDEA?

I have created a new Maven project using the CQ5 archetype and imported it into IntelliJ IDEA. IntelliJ marks usages of some classes such as org.apache.felix.annotations.Component, org.apache.felix.annotations.Reference, etc. IntellIJ as erroneous with the following error message:
The package is not exported by the bundle dependencies
Is this a legitimate error?
How can I fix it (as opposed to disabling the inspection)?
I'm using version 12.1.4
The error seems legit. I'm not able to find that package in the ACQ 5.6.1 Doc.
I turn off the inspection by:
Right-clicking on the block in the right margin.
Click "Customize Highlighting level".
Bring the slider down to "None".
Are you exporting those packages as part of the bundle definition? In the maven project, you should have the maven bundle plugin with <Export-Package>your.packages.here</Export-Package> defined. Are these packages included in that definition? If not, those services won't actually be availale in OSGi.
In my case, I accidentally "configured OSGi" when I only wanted to configure Spring. The way I dealt with this issue was by right clicking the right margin at one of the affected lines, clicking "Customize Highlighting Level" --> "Configure Inspections". I think hippoLogic's solution will get rid of all your syntax-level error highlighting as well as helpful inspection-level highlighting. This way you can simply tune the latter to exclude OSGi.
It'd be even better to de-configure OSGi (which I haven't investigated), but here's a quick/dirty fix to reduce the highlighting noise.
To Fix this check if the respective dependencies are present in the pom file, in your case I think it mught be present since you just imported them up from eclipse where it wasn't giving any error. Also check if the settings.xmml being referred to is correct, and is in right place and the correct one is been referred from intellij. your settings.xml is present in the maven home or might be reffered as a symbolic link in the maven home. Hope this helps.
just export related packages on maven build plugins as #Brenn's answer, deteails as below:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven.bundle.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-DocURL>${project.url}</Bundle-DocURL>
<Bundle-Activator>
org.apache.tika.parser.internal.Activator
</Bundle-Activator>
<Import-Package>
org.w3c.dom,
org.apache.tika.*,
*;resolution:=optional
</Import-Package>
<Export-Package>
your package here
</Export-Package>
</instructions>
</configuration>
</plugin>
I work on a project clone from github, it's unrelated about OSGI, so i think that's a bug of idea or i accidentally turn on . Then i assume the feature of "OSGI" in idea work depend on plugin,so i diabel this plugin
Disable the OSGI plugin, the error message disappear.
in mac os:
command + shift + a, type plugin
search "OSGI", then disable this plugin.

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