how to check if maven-install-plugin is available? - java

I'm trying to install ojdbc using maven install:install-file, with the command:
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc6-11.2.0.3.0.jar -DgeneratePom=true
From a ubuntu ec2-server and a cygwin command prompt, this works great.
From a third ubuntu 14.04 terminal running maven 3.2.5 and java 8, this fails with the error
[ERROR] The goal you specified requires a project to execute, but there is no POM in this directory (/home/user). PLease verify you invoked Maven from the correct directory
Technically, the error message is correct, I'm executing this from the directory containing the jarfile, and there is no pom in there. But install:install-file doesn't require a pom on any of the other servers I've tested the command on.
Is there a way to check that the maven-install-plugin is available? How to correct if it is not?

Related

How to deploy tools.jar into Nexus using Maven?

From the same directory I tried to deploy
spark-assembly-1.6.2.2.5.0.0-1245-hadoop2.7.3.2.5.0.0-1245.jar
and
tools.jar
(the later being a dependency of the first)
Despite launching the same commands:
mvn deploy:deploy-file -Dfile=./spark-assembly-1.6.2.2.5.0.0-1245-hadoop2.7.3.2.5.0.0-1245.jar -DgroupId="spark.yarn.jar" -DartifactId="spark-assembly-1.6.2.2.5.0.0-1245-hadoop2.7.3.2.5.0.0" -Dversion="1245-SNAPSHOT" -Dpackaging="jar" -DrepositoryId="stmms-id" -Durl="http://nexus.some.dns.com:8090/repository/maven-snapshots"
mvn deploy:deploy-file -Dfile=./tools.jar -DgroupId="jdk.tools" -DartifactId="jdk.tools" -Dversion="1.7.0_07" -Dpackaging="jar" -DrepositoryId="stmms-id" -Durl="http://nexus.some.dns.com:8090/repository/maven-snapshots"
the first is successfull but the second fails:
I also tried maven-deploy-plugin but with no much success.
Your repository maven-snapshots is a SNAPSHOT repository. You can only deploy SNAPSHOT versions to it.
So -Dversion="1245-SNAPSHOT" is ok, but -Dversion="1.7.0_07" is not.

Can't create a project from an archetype-catalog.xml

I'm trying to use my own project template, but when I perform the command:
mvn archetype:generate -DarchetypeCatalog=local
I got the following message:
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.
archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
Your filter doesn't match any archetype (hint: enter to return to initial list)
Choose a number or apply filter (format: [groupId:]artifactId, case-sensitive contains): :
I tried many possible solutions that I found here, but I did not succeed ...
My steps: - I created a project in eclipse -Then I went to root directory of this project and performed the following command in prompt:
mvn archetype:create-from-project
and had BUILD SUCCESS.
Then I performed the following command on project's folder
mvn install
and had BUILD SUCCESS
I checked the .m2 folder, and the archetpe-catalog.xml was there:
<?xml version="1.0" encoding="UTF-8"?>
<archetype-catalog xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<archetypes>
<archetype>
<groupId>io.openbdt</groupId>
<artifactId>framework-openbdt</artifactId>
<version>1.0</version>
<description>framework-openbdt</description>
</archetype>
</archetypes>
</archetype-catalog>
In maven's documentation explains that default path of archetypeCatalog=local is path/.m2/archetype-catalog.xml but on debug (mvn archetype:generate -DarchetypeCatalog=local -X), maven search the xml file in path/.m2/repository/archetype-catalog.xml
Note: These steps were typically performed in my notebook, but on my desktop I was unsuccessful. Then I created a new user on the notebook and it also didn't work anymore.
Can anyone help me, please?
Maven 3.5.2 is inconsistent location between read and write.
When set localRepository in settings.xml, mvn archetype:generate -DarchetypeCatalog=local command reads ${localRepository}/archetype-catalog.xml .
When without localRepository setting, that command reads ~/.m2/archetype-catalog.xml .
mvn archetype:update-local-catalog command creates ~/.m2/archetype-catalog.xml with maven-archetype-plugin v2.4.
That command creates ${localRepository}/archetype-catalog.xml with v3.0.1 .
refs:
[ARCHETYPE-529] Maven archetype:generate does not find local archetypes in interactive mode - ASF JIRA
I have the exact same problem and reproduced it with Maven versions 3.3.9 and 3.5.2. Probably something is inconsistent in how mvn install and mvn archetype:generate handle processing archetype-catalog.xml.
Because nothing helped for me as well, I created a soft-link:
ln -s PATH/TO/.m2/archetype-catalog.xml PATH/TO/.m2/repository/archetype-catalog.xml
This made the trick for me. Unfortunately, this works only for unix-like systems.

Using third party lib with maven

I'm trying to use Synthetica library with maven but I failed.
There are 2 different jar file I need to import. First one is synthetica.jar and the other one is syntheticablackeye.jar.
I tried mvn install:install-file but it didn't solve the problem.
I can use them with eclipse but currently I do not use any IDE like eclipse also I'm on linux.
Steps I have done:
(This is for synthetica.jar)
mvn install:install-file -Dfile=~/Dropbox/github/ChatAppServer/synthetica.jar -DgroupId=de.javasoft.plaf -DartifactId=synthetica -Dversion=1.0.0 -Dpackaging=jar
(This is for syntheticaBlackEye.jar)
mvn install:install-file -Dfile=~/Dropbox/github/ChatAppServer/syntheticaBlackEye.jar -DgroupId=de.javasoft.plaf -DartifactId=synthetica -Dversion=1.0.0 -Dpackaging=jar
the problem is how should I add dependency when the to jar files file structers are same?
I did these and It worked fine but when I check local mvn repos in my pc(.m2/repo/) there were no jar files. synthetica and syntheticablackeye file structers are same is this a problem? If it is what can I do?
What am I missing?
Edit: When I change artifactId and groupId maven trying to download jar files but they are in local repo?
You have not supplied any details about any errors you are getting or what command you used exactly to install the JARs, so it is hard to know what exactly is not working.
You can install 3rd party JAR files in your local Maven repository with a command like this (see also Maven's Guide to installing 3rd party JARs):
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id>
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
For example:
mvn install:install-file -Dfile=synthetica.jar -DgroupId=com.synthetica
-DartifactId=synthetica -Dversion=1.0 -Dpackaging=jar
Then you refer to it in the pom.xml of your project with the same Maven coordinates:
<dependency>
<groupId>com.synthetica</groupId>
<artifactId>synthetica</artifactId>
<version>1.0</version>
</dependency>
edit - Do not use the same groupId, artifactId and version for both JAR files, otherwise Maven cannot tell them apart.

Missing artifact com.oracle:ojdbc5:jar:11.2.0.1 error in pom.xml in eclipse

I have created a project in Eclipse using maven. I am getting an error in my pom.xml in dependency, the dependency look like this.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc5</artifactId>
<version>11.2.0.1</version>
<scope>provided</scope>
</dependency>
I am getting:
Missing artifact com.oracle:ojdbc5:jar:11.2.0.1
I saw a solution in stackoverflow it self, That-
due to Oracle license restriction, there are no public
repositories that provide ojdbc jar.
you need to download it and install in your local repository.
Get jar from Oracle and install it in your local maven repository using
mvn install:install-file -Dfile={path/to/your/ojdbc.jar} -DgroupId=com.oracle
-DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
the above command. I executed the bellow command changing the path to my ojdbc.jar.
mvn install:install-file -Dfile={
C/monitoring-workspace/ojdbc5.jar} -DgroupId=com.oracle
-DartifactId=ojdbc5 -Dversion=11.2.0.1-Dpackaging=jar
but I am getting an error on cmd that
I am confused in two things
My oracle folder it self has ojdbc5 and ojdbc6 jar then why do I need
to install ojdbc5
What should be the path I need to provide while installing ojdbc-the
where I need to install or the path where I have kept ojdbc5 jar.
I see you have referred to mykong article. The problem is new lines. You have to make sure that you got it in one line in the command prompt.
mvn install:install-file -Dfile=C:/monitoring-workspace/ojdbc5.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.1 -Dpackaging=jar
ojdbc6.jar - Classes for use with JDK 1.6. or newer
ojdbc5.jar - Classes for use with JDK 1.5.
you need only one of them

Trying to pass local jar to maven install

I'm trying to do a mvn install with my local jar.
Here is the pom file, Allure cli.
I want to use the allure-report-builder jar from my local machine, rather than from the maven repo. So I tried this:
mvn install:install-file -Dfile=allure-report-builder.jar -DgroupId=ru.yandex.qatools.allure -DartifactId=allure-report-builder -Dversion=2.1 -Dpackaging=jar install
Here allure-report-builder.jar is my local jar, in the current directory. But it doesn't seems to be working properly. The resulting jar is still using the jar from maven repo.
Where I'm making mistake?
You're trying to do two different things at once:
install:install-file -Dfile=allure-report-builder.jar -DgroupId=ru.yandex.qatools.allure -DartifactId=allure-report-builder -Dversion=2.1 -Dpackaging=jar
and
install
The first one is called a standalone goal. This will just install the file.
The second is called a phase, in this case the install phase. This will run every project-task/goal up until the install, which includes testing and compiling.
Depending on what you want, the first will always work. The second suggest that you have code to compile, but that you don't have all the required dependencies yet. If this is all fixed, you just run mvn install to get this jar in your local repository.

Categories