I installed my jars with:
install:install-file -Dfile="C:/Program Files/keydox/jkdx/codecs.jar" -DgroupId=keydoxWeb -DartifactId=keydoxWebCodec -Dversion=1.0
That worked fine and the jar also is in the .m2 repository.
But as I add them to the POM by:
<dependency>
<groupId>com.keydoxWeb</groupId>
<artifactId>keydoxWebCodec</artifactId>
<version>1.0</version>
</dependency>
I get the error message:
Failed to execute goal on project test: Could not resolve dependencies for
project com.TestOne:test:jar:0.0.1-SNAPSHOT: Could not find artifact
com.keydoxWeb:keydoxWebCodec:jar:1.0 in spring-snapshot
(http://repo.spring.io/snapshot)
When you installed your codecs.jar you set the -DgroupDId to be keydoxWeb, in your pom.xml you're trying to get the artifact with groupid com.keydoxWeb which does not exist since it is installed without com..
Related
My POM looks like this -->
<dependency>
<groupId>com.abc.xyz</groupId>
<artifactId>xyz</artifactId>
<version>1.0</version>
</dependency>
I have installed abc.xyz jar locally inside .m2 and is not available on mvn artifactory.
When I try to scan my code using sonar scanner installed on remote server, it tries to download abc-xyz.jar from maven artifactory & fails.
How do I make my remote sonar happy?
I tried giving scope as system but I see that it is deprecated.
Tried following
<scope>system</scope>
<systemPath>${project.basedir}/path/to/abc-xyz.jar</systemPath>
You can use sonar.exclusions in your pom.xml to exclude your jar-directory :
<properties>
<sonar.exclusions>${project.basedir}/path/to/abc-xyz.jar</sonar.exclusions>
<properties>
You might also try to define the property <sonar.skip>true</sonar.skip> in the pom.xml of the module you want to exclude.
Or try advanced reactor options like so: mvn sonar:sonar -pl !${project.basedir}/path/to/abc-xyz.jar.
I have a pom.xml with the following dependency:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
<type>bundle</type>
</dependency>
The dependency exists in Maven's central repo:
https://search.maven.org/artifact/com.fasterxml.jackson.core/jackson-databind/2.9.6/bundle
But when (using Eclipse) i right click on my pom.xml file and choose Run As -> Maven install, it downloads a bunch of dependencies related to that artifact, but finishes with the following error:
[ERROR] Failed to execute goal on project jackson-json-demo: Could not resolve dependencies for project com.elad:jackson-json-demo:jar:1.0.0: Could not find artifact com.fasterxml.jackson.core:jackson-databind:bundle:2.9.6 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
I tried a couple of other versions and also deleting the dependency from my local repo and trying again, but it didn't help. What could be the issue?
I have never heard of an artifact type bundle. Here's a list of some of the valid artifact type strings.
Just remove the <type /> tag from your dependency block and it will default to jar.
So I created my own remote repository with Dropbox following this tutorial. Further, I used the following command to deploy 3rd party JARS to my repository.
mvn deploy:deploy-file -DgroupId=com.prowritingaid.java -DartifactId=pro_writing_aid_java -Dversion=2.0.0 -Dpackaging=jar -Dfile=pro_writing_aid_java-2.0.0.jar -Durl=file:/home/de-10/Dropbox/ProWritingAid
The deployment was successful and it successfully synchronised with Dropbox as well. But now when I try to refer to these jars via pom.xml, it isn't working.
I added the Dropbox URL to my repositories list:
<repository>
<id>ProWritingAid</id>
<name>Remote ProWritingAid Repository</name>
<url>https://www.dropbox.com/sh/fbv...</url>
</repository>
and I've defined the dependencies like:
<!-- Keshavram Kuduwa's Dropbox Repository -->
<dependency>
<groupId>com.prowritingaid.java</groupId>
<artifactId>pro_writing_aid_java</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Keshavram Kuduwa's Dropbox Repository -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>2.7.5</version>
</dependency>
The compile-time error is:
Description Resource Path Location Type
Archive for required library: '/home/de-10/.m2/repository/com/prowritingaid/java/pro_writing_aid_java/2.0.0/pro_writing_aid_java-2.0.0.jar' in project 'papertrue' cannot be read or is not a valid ZIP file papertrue Build path Build Path Problem
But on the other hand, when I install these packages locally with the following, it works:
mvn install:install-file -DgroupId=com.prowritingaid.java -DartifactId=pro_writing_aid_java -Dversion=2.0.0 -Dpackaging=jar -Dfile=pro_writing_aid_java-2.0.0.jar
Moreover, if I delete these locally installed packages and force update the project, the error shows up again. I also replaced the JAR in the remote repository but it didn't help.
The Jar I was deploying didn't have a pom.xml file and hence the error. I tried something different, to use an in-project repository -> Creating an In-Project Maven Repository and deploying 3rd party JARs to it.
I have a compilation error in one of my projects
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
because it does not find all the classes from another project that I already included using
<dependency>
<groupId>com.laberint</groupId>
<artifactId>laberint-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
and I don't have any compilation problems from Eclipse. I already deleted all the repository.
The errors are because a missing classes that all are in the laberint-core artifact. I already deleted the whole repository folder
I also installed the jar
mvn install:install-file -Dfile=laberint-core-0.0.1-SNAPSHOT.jar -DgroupId=com.laberint -DartifactId=laberint-core -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar
Simply create a jar from your another project and add it in local lib directory of your current project. Another option is install the jar file in to your local maven repository like below:-
mvn install:yourlocal-jarfile
-Dfile=<path-to-your jar>
-DgroupId=<group-id> --> the group that the file should be registered under
-DartifactId=<artifact-id> --> give a artifact name to your jar
-Dversion=<version> --> version of your jar file
-Dpackaging=<packaging> --> jar
-DgeneratePom=true
Also you can try with below option:-
<dependency>
<groupId>com.laberint</groupId>
<artifactId>laberint-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<systemPath>/pathto/yourJar.jar</systemPath>
</dependency>
Hope this will help your. Good Luck!!!
As you stated in your comment you are developing the laberint-core project in the same Eclipse workspace as the project you are trying to build. The problem you have is that while Eclipse knows each project in your workspace and can resolve those project dependencies, Maven does not have this Information which means that it searches the repositories (your local one in ~/.m2 and Maven Central) for the dependency.
As you said, you have already installed the laberint-core project to your local Maven repository via mvn install. That's why Maven can find the dependency at all and you do not get a dependency could not be resolved exception but I would guess that you installed the dependency some time ago and so some of the classes that your created in the Eclipse project after installing are missing.
There are two ways how you can resolve this issue
Create and install the dependency jar each time before you build the main project
This means some more manual overhead when you are building the main project but it can be automated if you are only building in Eclipse and not directly from the command line.
Create an aggregator project as shown here.
This would basically be a third project that consists only of a pom.xml file that looks somewhat like this:
<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.laberint</groupId>
<artifactId>aggregator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>relative/path/to/laberint-core</module>
<module>relative/path/to/laberint-main</module>
</modules>
</project>
To build the project you would then call the goals you called on the main project before on the aggregator project. Basically if you called mvn package before from the root directory of the main project you would now change to the root directory of the aggregator project and call mvn package. By convention the aggregator pom should lay in the parent directory of its modules.
I'm trying to repackage log4j so I can use it with Android. In order to do so, I have to use openbeans library and replace each java.beans with com.googlecode.openbeans.
Obviously this is not sufficient, since before repacking the through maven log4j I've to include openbeans-1.0.jar in the project.
So I've found this method.
I've installed openbeans through the following command:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
I've checked that the correct execution of the command checking if the .jar exists in the following path (and it does):
~/.m2/repository/com/googlecode/openbeans/1.0/openbeans-1.0.jar
Then I edited the pom.xml file adding:
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
But if I try mvn package then this error is returned:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run (rmdir_tests_output) on project log4j: Execution rmdir_tests_output of goal org.apache.maven.plugins:maven-antrun-plugin:1.2:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.2 or one of its dependencies could not be resolved: Failure to find com.googlecode:openbeans:jar:1.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Like the install-file didn't worked.
I've tried also with this method, using the following code (obviously I copied the .jar in the project root dir):
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/openbeans-1.0.jar</systemPath>
</dependency>
And here the error returned is:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project log4j: Compilation failure
[ERROR] /home/luca/apache-log4j-1.2.17/src/main/java/org/apache/log4j/config/PropertyGetter.java:[31,21] error: package com.googlecode does not exist
What is wrong in what I'm doing?
Even if I still don't understand why, I found out that executing:
mvn install:install-file -Dfile=/home/luca/openbeans-1.0.jar -DgroupId=com.googlecode.openbeans -DartifactId=openbeans -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
And using in pom:
<dependency>
<groupId>com.googlecode.openbeans</groupId>
<artifactId>openbeans</artifactId>
<version>1.0</version>
</dependency>
The code is compiled without error. But as I said, still wondering why.