Maven failed to execute goal (Could not resolve dependencies) - java

I haven't worked with Java in many years as I primarily work with PHP (Using Composer for dependency management). I've only just started looking at Maven and Gradle too.
I'm trying to have a play around using Maven and wanted to use Eclipse's JDT UI tools so I could have a go at a test project building a user interface using some of their components, just to try and bring myself up to speed.
I'm using Maven to try and bring in the JDT UI package as a dependency. This is my pom.xml:
<?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>com.jonathon</groupId>
<artifactId>ui-test</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.12.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.ui</artifactId>
<version>3.12.2</version>
</dependency>
</dependencies>
</project>
I'm using IntelliJ IDEA as my IDE and it seems to be complaining in a tooltip about not being able to resolve dependencies. I tried running mvn compile to see if I could get a better error message and I got this:
[ERROR] Failed to execute goal on project ui+test: Could not resolve dependencies for project com.jonathon:ui-test:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.eclipse.jdt:org.eclipse.jdt.ui:jar:3.12.2 -> org.eclipse.platform:org.eclipse.search:jar:3.11.1 -> org.eclipse.platform:org.eclipse.ui:jar:3.108.1 -> org.eclipse.platform:org.eclipse.swt:jar:3.105.2 -> org.eclipse.platform:org.eclipse.swt.gtk.linux.aarch64:jar:[3.105.2,3.105.2]: No versions available for org.eclipse.platform:org.eclipse.swt.gtk.linux.aarch64:jar:[3.105.2,3.105.2] within specified range -> [Help 1]
Am I doing something wrong? I got the artifactId, groupId and version from here.

This library is the problem org.eclipse.platform:org.eclipse.swt.gtk.linux.aarch64:jar it doesn't exist at all.
gtk.linux.aarch64 this part is resolved from your setup or java/system
propably you need to set osgi.platform=gtk.linux.x86_64 in your mvn pom or env .

Related

Seems that methods of maven repository can not be called from end-product

I am setting up a Craftbukkit Server with the editor IntelliJ and the programming language Java. For that I use firebase-admin. I want use it trough maven and everything works. But when I build the .jar and then let it run it returns following error in the console:
java.lang.NoClassDefFoundError: com/google/firebase/FirebaseOptions$Builder
at raycroud.mckaff_server_manager.ServerManager.onEnable(ServerManager.java:26) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:254) ~[craftbukkit-1.13.2.jar:git-Bukkit-a4c555b]
I am sitting at this problem for many days and tried many different solutions, but nothing worked.
Here you can see my project structure:
And here my Artifacts Settings under File->Project Structure->Artifacts:
Here is my pom.xml 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>company.lol_server_manager</groupId>
<artifactId>server_manager</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.6.0</version>
</dependency>
</dependencies>
</project>
Actual the Craftbukkit plugin gets disabled but I normally I expect that he works and I don't know why he can find methods or other elements from maven libraries.
There could be several reasons.It would help if you provide your run/debug configuration.You could try the following:
Activate [Include in project build].
Let me know if it helps.

How to structure a new project in maven so it finds jar files and doesn't give dependency errors

TIL like I'm 5. I am not a developer. I've downloaded two udemy courses on maven and gone through both as well as gone through http://maven.apache.org/guides and nothing I've gone through really explains how to set up a project with a local (not remote) repo and what to configure and I'm getting embarrassed at how long I've spent today on trying to figure this out.
My senior person has set up a project that has the main framework things I need to plug in my scripts to run automation. I'm creating feature files/step def files on a certain project and it all uses her UI framework project with the webdriver/properties information I need. She's compiled this project in a jar file: CoreAutomationLibrary-0.0.1-SNAPSHOT.jar
Then I try to run a maven install on my project to get an initial build success so I can go through with creating my more tailored scripts.
Here is my current POM:
<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>MyAutomation</groupId>
<artifactId>MyAutomation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyAutomation</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>CoreAutomationLibrary</groupId>
<artifactId>CoreAutomationLibrary</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
I'm not sure where to put this jar file.
For instance, I have her project downloaded to:
Users/myName/eclipse-workspace/HerProject
And I have my project downloaded to:
Users/myName/eclipse-workspace/RestAssured/MyProject
This jar file is floating around now, I keep moving it. I had it in my project folder just independent of anything. I tried putting it target. I'm not sure where it goes. I thought the important thing was just that it was in the build path for the project, which it is.
When I run maven install:
WARNING] The POM for CoreAutomationLibrary:CoreAutomationLibrary:jar:0.0.1-
SNAPSHOT is missing, no dependency information available
[INFO] ---------------------------------------------------------------------
---
[INFO] BUILD FAILURE
[INFO] ---------------------------------------------------------------------
---
[INFO] Total time: 0.221 s
[INFO] Finished at: 2018-06-22T11:32:44-05:00
[INFO] Final Memory: 7M/243M
[INFO] ---------------------------------------------------------------------
---
[ERROR] Failed to execute goal on project COM_UI: Could not resolve
dependencies for project COM_UI:COM_UI:jar:0.0.1-SNAPSHOT: Could not find
artifact CoreAutomationLibrary:CoreAutomationLibrary:jar:0.0.1-SNAPSHOT ->
[Help 1]
Maven usually deals with downloading dependencies itself. Propably the easiest solution in the long run is to host a repository manager like Nexus or Artifactory. Then you can configure your local maven to use this as a repository.
If this is not possible for you, you have to install the jar to your local repository using
mvn install:install-file -Dfile=Users/myName/eclipse-workspace/HerProject/her.jar -DgroupId=CoreAutomationLibrary -DartifactId=CoreAutomationLibrary -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar

class import not resolved on external jars installed in maven local repository

I am using maven 3.2.5. I have one external jars which I need to use in my maven project which is not available in maven repository.
I installed those jars by using following command:
1) mvn install:install-file -Dfile=p-unit-0.15.319.jar -DgroupId=org.punit -DartifactId=p-unit -Dversion=0.15.319 -Dpackaging=jar
2) After this command, I saw in my M2 repository, jar & pom was created
.m2\repository\org\punit\p-unit\0.15.319\p-unit-0.15.319.jar
.m2\repository\org\punit\p-unit\0.15.319\p-unit-0.15.319.pom
created pom content:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.punit</groupId>
<artifactId>p-unit</artifactId>
<version>0.15.319</version>
<description>POM was created from install:install-file</description>
</project>
3) Updated the pom file
<dependency>
<groupId>org.punit</groupId>
<artifactId>p-unit</artifactId>
<version>0.15.319</version>
<scope>provided</scope>
</dependency>
Issue: When I tried to use class of this jar,
import org.punit.runner.*;
getting error: import org.punit.runner can't be resolved.
I tried many combination to define the dependency but not able to use the classes.
How can I resolve it??
Add the corresponding dependency to the pom.xml file of your project under the tag dependencies.
Example :
<dependencies>
<dependency>
<groupId>org.punit</groupId>
<artifactId>p-unit</artifactId>
<version>0.15.319</version>
<scope>test</scope>
</dependency>
</dependencies>
Note : assuming the group,artifact ids and version are correct as mentioned in the question.
One thing which I missed, I am mentioning here, which solved this issue.
I had put the dependency in wrong profile which was not called during my compilation.
When I put in correct profile it worked.
Second option:
We can directly add external jar through eclipse:
Properties -> Java Build Path -> Libraries -> Add External Jars.
and locate the library on the file system.
Answer to similar query:
The import org.junit cannot be resolved

Eclipse NoSuchMethod exception; configuring build path

I have a maven project which actually builds as multiple java projects. Project B contains a class which is a child of a class sin Project A. When I try to run this class in a debugger I get a NoSuchMethod error when the method tries to call any functionality from it's parent.
The Maven setup is designed to compile every single project and place it in the maven repository so other projects can find them (it has a sense of dependency so it builds pre-req projects firsts). This is all good for deployment, but I don't want to force people debugging in eclipse to do a maven install every time the start up their debugger. Instead I tried adding pre-req projects to the class path of the applicable projects (build path -> add class folder). This doesn't work. I think it's due to having both the maven repository and the class path in my build path? but the class folders should be parsed forced and the newer class folders should be parsed before the maven install right?
How can I configure this to work without needing to re-do a maven install each time?
What exactly do your pom files look like? I often use a setup where I have one parent Maven project that is comprised of other Maven sub projects.
I will have a parent pom that looks something like this:
<?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">
<groupId>put group id here</groupId>
<artifactId>name of artifact id</artifactId>
<version>0.2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>example-subproject-1</module>
<module>example-subproject-2</module>
</modules>
</project>
I'll then have pom files in the subprojects that look like this (assume this is the pom file for subproject 1):
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<artifactId>artifact id of parent pom</artifactId>
<groupId>group id of parent pom</groupId>
<version>version number of parent pom</version>
</parent>
<groupId>group id</groupId>
<artifactId>artifact id</artifactId>
<packaging>packaging</packaging>
<version>1</version>
<name>put name here</name>
<dependencies>
<dependency>
<groupId>group id of example subproject 2</groupId>
<artifactId>example-subproject-2</artifactId>
<version>version number of example subproject 2</version>
</dependency>
</dependencies>
</project>
When I have things set up this way, I can compile the entire project if I'm in the root directory. If I just want to compile a specific directory, I just change into that directory. Make sure to include any needed subprojects in your dependencies section.
Make sure you have the m2eclipse plugin installed.
http://eclipse.org/m2e/download/
Also, install the m2eclipse-wtp plugin
http://marketplace.eclipse.org/content/maven-integration-eclipse-wtp#.UUdUhBxwrIU
Make sure you have created your projects as 'Maven' projects. So, if you look at your 'ProjectA->Properties->Builders', you should see a 'Maven Project Builder'.
If you follow all above steps, your project dependencies should resolve correctly and you should not have errors.
If you still have errors, pls post your eclipse project structure.

by using maven Build projects and deploy it using jboss-maven-plugin

I have 2 (core, core-web) projects such a way that one is depending on another.
so the core-web's POM.xml contains the dependency of core.
core-web will be deployed on jBoss AS (5.1). Therefore want to use jboss-maven-plugin
I have to run install on both core and core-web after every change and have to deploy the file manually. Everything is seems to be working fine if I put the war file to the deploy.
Just want to ask that if there is a way that I can make a routine in core-web's POM that it automatically generates core.jar and core-web.war and deploy it to the running jboss server on localhost:8080 port.
Please let me know if there is more information you require.
Thanks in advance.
I think I have found the issue. I made another pom.xml and and added core and core-web in the module tag and now I have to install this new pom and it installs all the dependent poms in a sequential way.
<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>
<artifactId>build-all</artifactId>
<packaging>pom</packaging>
<name>build-all</name>
<parent>
.......
</parent>
<modules>
<module>..</module>
<module>../core</module>
<module>../model</module>
<module>../cas-server</module>
<module>../core-web</module>
<module>../other-projects</module>
</modules>
</project>

Categories

Resources