I'm building a SonarQube plugin and I need to use Maven to achieve it, I must use the goals clean package to create the jar file that acts as the plugin. My problem is that I need to load either a local jar file, which didn't worked as I tried using: <systemPath>${project.basedir}/lib/epsilon-1.3-core.jar</systemPath> to load it as a dependency and Maven wasn't able to resolve it or I must load three external projects which are at my workspace but I don't know how to tell maven to include them.
Could someone help me to do this? I'd really appreciate it! Using my own Maven repo (with Nexus for example) isn't an option.
I had to do a local maven repository loading the plugins of Epsilon as jar files, it's a temp solution while the Epsilon Team setup a maven repo.
Related
I am using the maven embedded eclipse.
Tried :
Deleting the whole m2 repository.
Maven->Update Project.
Run as -> Maven Build
User settings file does not exist(Please don't tell me it has to something with this file)
settings.Xml file
This file is only required if you are using a proxy and i am not
I have every dependency present in pom.xml file of my project but still eclipse is not able to import all these dependencies in the project
I have attached the photo below. Please help me to resolve my issue
mvn dependency:tree
Maven Dependencies
POM.xml file
List of dependency present in pom file of my project
None of the methods mentioned above worked so please help me to solve this issue.
Is there anything related to maven or eclipse version ?
When you execute mvn dependency:tree result shows an error related to "i cannot obtain some jar", it may be due to private reporitory.
If you are working with private repository, make sure you configure access in $HOME/.m2/settings.xml
On another hand I see you are working with snapshots. If you are trying to bind projects you have in your local host machine, ensure you are executing mvn install (or better mvn source:jar install) sucessfully and your system's maven is pointing the same .m2 path that refers Eclipse maven plugin
It seems using the Spring framework Maven repository via HTTP instead of HTTPS causing this issue.
In your pom.xml file replace http://maven.springframework.org with https://maven.springframework.org.
I am using Maven in my project, and for some reasons, some additional jars should be added manually (I have followed the step like Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project).
The package can be imported successfully. However, the compilation error happens, which indicates the package does not exist and cannot find the symbol of the used object.
I have tried the following tips but it remain unchanged:
Invalid caches / restarts
reimport
delete .idea file and .iml file
The scenario is quit similar to this one : https://intellij-support.jetbrains.com/hc/en-us/community/posts/206821195--beginner-question-including-external-jar-compile-error.
Please see the following sample images. It may run successfully but cannot be compiled well.
The reason is that when you add a library manually via IntelliJ, only IntelliJ knows about them and when you compile your code using Maven, it can't be find by Maven because Maven only searches for dependencies you defined in pom.xml.
You should install your libraries in your (at least) local maven repository and add them as a normal dependency in your pom.xml. Then you don't need to add them manually in IntelliJ.
You should follow the steps mentioned at Guide to installing 3rd party JARs
Update:
Also you should note that if you're working as a team, you should install this on the local maven repository of all developers (which is not practical). The best solution is to install a Maven repository (e.g. Nexus, Artifactory or Archiva) in a server on your local network and upload your private jar files on those servers. Then all developers can define the address of the local Maven repository server in their local Maven settings and use artifacts/libraries from that servers. Plus it works as a local cache/proxy to fetch any Maven artifacts and prevents unnecessary calls to public maven repositories.
I have a multiple-module project using STS4/JDK10. When my modules appear in the Maven dependencies of another of my modules, they always show with '(without test code)" rather than a version such as "1.0.0.jar - {repository location}". I have used Run/Maven Install the jar to my Maven repository and I have used deploy to put in my Archiva repository. Some of these modules have Junit tests. Is there a way to resolve the issue?
Am I missing something in my module-info file or my pom?
This is not because of you missed anything in pom. In fact this is a feature in eclipse, related to maven.
To see the jar(as you are expecting), follow the below steps:
Right click on module->Maven->Enable Workspace Resolution.
These steps solve you problem.
I'm building a project where the final war/jar size is very big. I am not sure how to reduce the size of the jar.
How to build only the jars required for the project?
Currently we just given maven build plugin in the dependencies and artifact id on the top which builds the war or jar
Please advise.
Thanks.
use dependency:analyze on your project to analyze used and unused dependencies, so you can exclude unwilling dependency files, i search a lot for a plugin to do it automatically, but I get disappointed in it. if you find please inform me.
https://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html
JAR files typically don't include dependencies, so unless you're building a so-called fat JAR, they should never get very big.
For WAR files:
Remove unneeded dependencies from your POM.
Optionally, move static assets (images etc.) to a web server instead of including them in your application.
If you have dependencies that are being used by multiple applications, include them on the application server level instead of inside your WAR file.
You can use the combination of two mvn commands:
1] mvn dependency:tree -> to understand the entire structure of jars in your project
2] mvn dependency:analyze -> as mentioned above to understand used and unused dependencies
after that you can start removing unused dependencies and always make sure to do mvn clean install and run your project locally to see if there are dependency issues.
I've been trying to add a custom .jar (ftp://ftp.ncbi.nlm.nih.gov/pub/eutils/soap/v2.0/java/axis2_1.5.2_jdk_6.0.12/eutils_axis2.jar) to a project that doesn't have a central corporate maven repository and that instead will have the custom JARs checked into SCM in the project directory tree. I was following this post to make it happen: Maven: add a dependency to a jar by relative path (awesome post btw).
What I did was:
Add local repository to pom.xml
install the file into the local repository
Add dependency to pom.xml
Based on what I see in m2eclipse, the library has been successfully recognized by Maven and added to the dependency list (or it'd be called ? : ? or something similar)
The problem is that Eclipse still doesn't see the referenced lib, so this still fails:
import gov.nih.nlm.ncbi.www.soap.eutils.*;
Pardon my maven newbiness, but what are changes / next steps I need to make to get to:
Have Eclipse see the library so that autocomplete works (and the import can be resolved)
Be able to compile the project
Be able to execute the jar produced by mvn package?
Thanks!
If you see the JAR under "Maven Dependencies" in your project, Eclipse should be able to see and use it. If it's not there, then m2eclipse wasn't able to resolve the dependency properly.
If it is missing, m2eclipse was unable to download the dependency from your local repository for some reason. Check the Maven 2 Console for errors and the Problem View.
Lastly, the JAR itself might be corrupt. Maven doesn't check for that, it simply adds the file to the classpath. If Eclipse can't open the JAR, you can also get the errors you mentioned.