Maven Local file installation - maven

I am trying to install a local jar file to be used as a dependency using the following command
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=<path-to-file>
Getting the following result
The goal you specified requires a project to execute but there is no POM in this directory

To install the file in the local maven repository, you have to provide also the group ID, artifact ID, and the version for that file. Without them, Maven does not know in what directory to store the file.
See also: https://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html.

Maven need the so called GAV coordinates: groupId, artifactId, version and packaging to store the artefact.
You can name them wiht the install command
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file
-Dfile=<path-to-file>
-Dpackaging=jar
-DgeneratePom=true
-DgroupId=<groupId> -DartifactId=<artifactId> -Dversion=<version>

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 do add ucanaccess maven dependency in pom.xml

I can't get the maven dependency for ucanaccess to work:
net.ucanaccess
ucanaccess
2.X.X
It doesn't seem to be available?
It appears that ucanaccess is not currently available from maven central (based on googling for it and finding this thread).
I'd recommend downloading it from sourceforge, extracting the jar, and installing the jar in your local repo using the instructions from the maven documentation:
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
Where: <path-to-file> the path to the file to load
<group-id> the group that the file should be registered under
<artifact-id> the artifact name for the file
<version> the version of the file
<packaging> the packaging of the file e.g. jar
Did you look on http://mvnrepository.com/ to check whether your dependency is present or not ?
If not you should drop the jar in your classpath by yourself or create the appropriate directory in your local maven repository at %HOME%.m2\repository.

How can i add a self created jar say jarFile.jar to pom.xml

i have created a jar with name jarFile.jar, as you can see i haven't mentioned any version of the jar which is creating problem while i trying to add this jar to pom.xml without changing the name of the jar
`<dependency>
<groupId>com.my.jar</groupId>
<artifactId>jarFile</artifactId>
<version></version>
</dependency>`
If you don't specify version, maven can't know which jar to take.
Specify the version of the jar you installed.
The procedure to install a jar i use is:
mvn install:install-file -DgroupId=com.example -DartifactId=awesomeJar -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true -Dfile=C:\myJar.jar
(for external jars)
or
mvn clean install -o
from the project folder for installing my own dependency jars.
I don't see the real question here.

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.

Warning POM missing in the jar

I have created the jar through maven from some other project. The jar reside in the location repository. The jar contains the pom.xml file in META-INF/maven///pom.xml
and pom.properties.
I have also copied the pom.xml file while running the pom for that project using resource-copy
plugin. Still I am getting the below warning , there fore during the building of war the maven not able to include all the dependent jars of the above jars in the war file. Other option is to add thoses jars as a runtime dependency in my war pom file.
[WARNING] The POM for org.artifact:runtime.ui:war:1.0.0-SNAPSHOT is missing, no dependency information available
I found that only goal packaging will put the artifact in a local repository. But then for each artifact I need to do the install so that it will get in the files system repository with the pom file. Copying the pom file using resource plugin will not help.
Hi you need to install the specific jar to your local repository (for a start).
If this jar is properly packaged using maven you can issue the following command from the terminal:
mvn install:install-file -Dfile=<path-to-file>
If it is custom made you need to include the required parts like
mvn install:install-file -Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging
Please see the official documentation here.
Hope it helps

Resources