maven: local installed jar not found - maven

I'm getting this error message:
Could not resolve dependencies for project com.psgd.template:backend:war:1.0.0: Could not find artifact com.oracle:ojdbc7:jar:12.1.0.2
I've previously installed this library into local repository using:
mvn install:install-file \
-DgroupId=com.oracle \
-DartifactId=ojdbc7 \
-Dversion=12.1.0.2 \
-Dpackaging=jar \
-Dfile=ojdbc7-12.1.0.2.jar \
-DgeneratePom=true
I've look up into my repository:
$ ls -Rh ~/.m2/repository/com/oracle/
/home/jeusdi/.m2/repository/com/oracle/:
ojdbc7
/home/jeusdi/.m2/repository/com/oracle/ojdbc7:
12.1.0.2
/home/jeusdi/.m2/repository/com/oracle/ojdbc7/12.1.0.2:
ojdbc7-12.1.0.2.jar.lastUpdated ojdbc7-12.1.0.2.pom.lastUpdated
So, it's present into local repository.
Any ideas?

Many things can go wrong here.
When you run mvn install:install-file you should see the log line in command line: something like : INFO Installing file ... to full <<PATH_COMES_HERE>>
So check that path.
If everything works as expected you should be able to see both pom.xml and the jar in the corresponding folder of your repository, not "lastUpdated" I believe.
I don't see it in the provided snippet...
You can also check permissions as one possible source of issues.
The last thing is checking the actual pom generated by install:install-file. Make sure, the pom is valid and contains the information you've entered.
You can also delete the whole folder from maven repo and re-run mvn install:install-file maybe the repo went corrupted for some reason who knows.

The files
ojdbc7-12.1.0.2.jar.lastUpdated ojdbc7-12.1.0.2.pom.lastUpdated
mean that the Maven looked for the pom and did not find it. It is a kind of cache for missing artifacts.
Please delete these two files and try again to install the jar. Then try again to build against it.

Related

project.build.finalName is not working with deploy-file goal

can we use project.build.finalName in the command line options of the mvn deploy:deploy-file goal.
here is my command:
mvn deploy:deploy-file -DgroupId=abc -Dproject.build.finalName=test -DartifactId=test -Dversion=1.0 -Dpackaging=jar -Dfile="file_path" -Durl=url -DrepositoryId=id`
the details are :
first, there is no POM file available.
i am just executing this command to upload the artifact in nexus.
now the issue is , the artifact being uploaded has the name as : ${artifactId}-${version}
and i dont want version in the finalname. i have alrady gone through the couple of posts and found that we can use project.build.finalName
but in this case , it is still uploading with version number. how can i fix that ?
You need to drop the -Dproject.build.finalName part and add -DgeneratePom=true instead, as you're already specifying the full path to the artifact via the -Dfile.
You cannot not have the version part when deploying to a Maven remote repository (which is what you're trying to do). When deploying to a Maven repository, your artifact's GAV (groupId, artifactId, version, type and classifier) coordinates will get translated into:
${groupId}/${artifactId}/${version}/${artifactId}-${version}.jar
For example, for these GAV-s:
groupId : com.foo
artifactId : bar
version : 1.2.3-SNAPSHOT
type : jar
classifier : [null, javadoc, sources]
You will get a path like:
com/foo/bar/1.2.3-SNAPSHOT/bar-1.2.3-SNAPSHOT.jar
com/foo/bar/1.2.3-SNAPSHOT/bar-1.2.3-SNAPSHOT-javadoc.jar
com/foo/bar/1.2.3-SNAPSHOT/bar-1.2.3-SNAPSHOT-sources.jar
The -Dproject.build.finalName is for cases, where you'd like the artifact to have a different name so that, (for example), your build process can use that for simplicity, or convenience.
If you're deploying using deploy-file and have no pom.xml file, your command-line should look something like this:
mvn deploy:deploy-file \
-DgroupId=com.foo \
-DartifactId=bar \
-Dversion=1.2.3-SNAPSHOT \
-Dpackaging=jar \
-Dfile="path\to\foo-1.2.3-SNAPSHOT.jar" \
-Durl=http://the-url-to-your-repository/ \
-DrepositoryId=the-repository-id-defined-in-your-settings.xml-that-has-your-credentials

How to install Maven archetype from local JAR and POM, and also update local catalog

I want to distribute a custom archetype JAR and POM, without deploying them to a Maven repository, so that someone can grab them and install in their local repository with something like a mvn install:install-file -Dfile <file> -DpomFile <pom>.
But if one just does:
mvn install:install-file -Dfile=./my-archetype-1.0.jar -DpomFile=./my-archetype-1.0.pom
the local catalog doesn't get updated.
Though there are similar questions like this, this and this, they left me missing a small step.
I'm not sure how to run the mvn archetype:update-local-catalog that they mention. Where's the pom.xml?
Simply run mvn -f <archetypePomFile> archetype:update-local-catalog doing a mvn -f pointing to the archetype pom.
So altogether it's:
Install archetype
mvn install:install-file -Dfile=./my-archetype-1.0.jar -DpomFile=./my-archetype-1.0.pom
Update local catalog
mvn -f my-archetype-1.0.pom archetype:update-local-catalog
Maybe that's obvious to others reading the doc but I spent enough time on this that I thought I'd write it up.

Missing parent pom for Intuit's Java V3 SDK for QBO

I'm updating to the latest version (2.3.2) of the Java V3 SDK for QBO. Following the instructions on the IPP developer site, I'm running into issues on Step 5: Install the Dependencies.
I checked out the sample application (which uses a deprecated version of the API) as listed in the documentation. After modifying the the maven install commands listed in the documentation to match the versions in the sample application, I can install the deprecated SDK dependencies:
## ipp-v3-java-devkit-2.0.1-jar-with-dependencies.jar
mvn install:install-file
-DgroupId=com.intuit.code.devkit.v3
-DartifactId=ipp-v3-java-devkit
-Dversion=2.0.1
-Dpackaging=jar
-Dfile=./QuickbooksV3API-Java/QuickbooksV3API/src/main/resources/dependencies/ipp-v3-java-devkit-2.0.1-jar-with-dependencies.jar
## ipp-java-qbapihelper-1.2.0.jar
mvn install:install-file
-DgroupId=com.intuit.code.devkit.qbhelper
-DartifactId=ipp-java-qbapihelper
-Dversion=1.2.0 -Dpackaging=jar
-Dfile=./QuickbooksV3API-Java/QuickbooksV3API/src/main/resources/dependencies/ipp-java-qbapihelper-1.2.0.jar
At this point I am able to run the sample application and successfully connect to QBO via the API.
Now that I've downloaded the latest IPP V3 Java SDK (24MB download) provided in the documentation the maven install command fails:
## ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar
mvn install:install-file
-DgroupId=com.intuit.code.devkit.v3
-DartifactId=ipp-v3-java-devkit
-Dversion=2.3.2
-Dpackaging=jar
-Dfile=./ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar
Resulting in:
[ERROR] The project com.intuit.code.devkit.v3:ipp-v3-java-devkit-pom:2.3.3-SNAPSHOT
(C:\...\JavaV3SDK2.3.2\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find
com.intuit.sb.tool.build.parent-pom:sb-parent-pom:pom:5.0.2
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 and
'parent.relativePath' points at wrong local POM # line 4,
column 10 -> [Help 2]
I've searched high and low for this parent POM artifact to no avail: com.intuit.sb.tool.build.parent-pom:sb-parent-pom:pom:5.0.2
Should the latest SDK download include the parent POM or am I missing something else?
I've installed the latest devkit(2.3.2) in my local maven repo.
It looks like a caching issue.
Please check if you have the devkit jar in the local repo.
<root>\.m2\repository\com\intuit\code\devkit\v3\ipp-v3-java-devkit\2.3.2
If you still face this issue, you can try deleting the above '2.3.2' folder and install it again.
mvn install:install-file -DgroupId=com.intuit.code.devkit.v3 -DartifactId=ipp-v3-java-devkit -Dversion=2.3.2 -Dpackaging=jar -Dfile=C:\ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar
Thanks
Place the updated jar (ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar) alongside the previous one in the sample application, specifically: QuickbooksV3API-Java\QuickbooksV3API\src\main\resources\dependencies\
Now run maven install as before, just change the version numbers:
mvn install:install-file
-DgroupId=com.intuit.code.devkit.v3
-DartifactId=ipp-v3-java-devkit
-Dversion=2.3.2
-Dpackaging=jar
-Dfile=./QuickbooksV3API-Java/QuickbooksV3API/src/main/resources/dependencies/ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar
While I'm not exactly sure why this works, I assume it has something to do with resources in paths relative to the jar itself.
The problem weird. apperantly what it looks like is the pom.xml inside dev-ki that comes along is broken.
When you run any command in the devkit directory, it uses that pom.xml within the devkit,and fails.
what I did was I went one directory up, and then tried importing the jar again. something like this -
mvn install:install-file -DgroupId=com.intuit.code.devkit.v3
-DartifactId=ipp-v3-java-devkit -Dversion=2.3.2 -Dpackaging=jar -Dfile=devkit/ipp-v3-java-devkit-jar-with-dependencies-2.4.0.jar
Interestingly this works. All of my developer jars are kept in dev-kit.
the devkit pom.xml had issues with parent module and child module, What it looks like is that the pom is just for reference, and not for execution.
-Hope this helps.

install maven archetype project jar with *.pom file to local repo

i`m kinda new to maven and want to know how to install an archetype jar to my local repo
i got a directory com.foo with the following files:
maven_metadata_local.xml
[1.00.00-SNAPSHOT]
which containes these files
_maven.repository
foo-archetype-1.00.00-SNAPSHOT.jar
foo-archetype-1.00.00-SNAPSHOT.pom
maven_metadata_local.xml
from what i read i understand that there is a way to build a template project using this archetype but first i need to install it to my local repo
how can i do this?
thanks
i managed to do that:
what i did is opened the maven_metadata_local.xml to get the groupId, artifactId, and version
run this command from that directory
mvn install:install-file
-Dfile=foo-archetype-1.00.00-SNAPSHOT.jar \
-DgroupId=com.foo \
-DartifactId=foo-archetype \
-Dversion=1.00.00-SNAPSHOT \
-Dpackaging=jar \
-DgeneratePom=true
once compleated (BUILD SUCCESS) i got the build in my local repository
go to a folder from which i want to create a project
run this command
mvn archetype:generate \
-DarchetypeGroupId=com.foo \
-DarchetypeArtifactId=foo-archetype \
-DarchetypeVersion=1.00.00-SNAPSHOT \
-DgroupId=com.mycom \
-DartifactId=myApp \
-Dversion=myversion-SNAPSHOT
in eclipse i imported an existing maven project, right click on the project->maven->update
and i got the full build ready to work
Adding an archetype to your local repository is no different than adding any other dependency. You can simply run a mvn install command on it.

mvn clean install, mvn install:install-file order?

I am learning maven and trying to understand the order of things. As I understand, mvn clean install builds the repository with the default jars, where install produces a .zip that I will need later.
I want to use my custom jars which I call mvn install:install-file, but when I run this before install, I get some cannot find symbol errors. I am assuming my custom jars (which don't contain these classes) overwrites some default jars? I can't find these classes anywhere on my filesystem, so I am assuming they are already packaged in 1 of the default jars. How can I get around this?
Also, which order should I do things? All I want is the final .zip, that includes the custom jars?
mvn install -- builds and packages the source code and copies ( installs ) the artifact to your local repository which is $USER_HOME/.m2/repository
It's hard to say what's happening there without looking at the command you typed in, and the error trace that you received. That said, install-file is to copy an artifact to your local repo at appropriate hierarchy. It's nothing more than that. The correct syntax would be:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Usually, you just need to run install:install-file for all the custom dependencies once, and before you execute the mvn install.
If your custom jars have same coordinates -- artifactid, groupid, and version as some of the dependencies in your pom.xml and your custom jars do not have the classed that your source code uses -- well, you get the error.
refer: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Regarding to the maven-install-plugin website they mention as the following: -
install:install-file: is mostly used to install an externally created artifact into the local repository, along with its POM. In that case the project information can be taken from an optionally specified pomFile, but can also be given using command line parameters.
This means the artifact should be created before using this command. If you would like to deploy your fresh compiled code to the local repository, please just use the mvn clean install.
Please look at the Introduction to the Build Lifecycle for further information about the sequence and lifecycle. I hope this may help.
Regards,
Charlee Ch.

Resources