Install manually jar file - java

Install manually jar file into repository.
I want to install this SDK as maven dependency.
https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_accounting/0200_java/0002_installing_the_java_sdk_for_quickbooks
I tried this:
mvn install:install-file -DgroupId=com.intuit.code.devkit.v3 -DartifactId=ipp-v3-java-devkit -Dversion=2.5.0 -Dpackaging=jar -Dfile=c:\lib\ipp-java-qbapihelper-1.2.1-jar-with-dependencies.jar
But I get
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # standalone-pom ---
[INFO] Installing c:\lib\ipp-java-qbapihelper-1.2.1-jar-with-dependencies.jar to C:\Users\plamen\.m2\repository\com\intuit\code\devkit\v3\ipp-v3-java-devkit\2.5.0\ipp-v3-java-devkit-2.5.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.631 s
[INFO] Finished at: 2016-09-02T17:04:51+03:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
When I browse my local repository I can't find any jar file into the directory. Can somebody give some advice how I can fix this?

What I've done in the past to make this work is:
Copy the jar file(s) of interest to a temp folder i.e. project root/tmp
Run the following command (adjusting the parameters accordingly) in the command line from the the project root directory:
mvn install:install-file -Dfile=tmp/<filename>.jar -DgroupId=intuit.code.devkit.v3 -DartifactId=ipp-v3-java-devkit -Dversion=2.5.0 -Dpackaging=jar -DlocalRepositoryPath=<repo path> (i.e. src/dependencies/jars)
After that command you should see a src/dependencies/jars/com/... directory with maven artifacts under it
Add dependency to your pom.xml
<!— <project> is the parent element —>
<repositories>
<repository>
<id>system-jars</id>
<url>file://${basedir}/src/dependencies/jars</url>
</repository>
</repositories>
<!— Add the dependency —>
<dependency>
<groupId>com.intuit.code.devkit.v3</groupId>
<artifactId>ipp-v3-java-devkit</artifactId>
<version>2.5.0</version>
</dependency>
Perform a maven clean and package. Verify the classes are included in the end artifact and then delete the tmp directory once everything is correct.

Related

Maven does not find local dependency

TL;DR
Maven does not find <importedGroupid>:<importedArtifactid>:jar:1.0 in repository file://<homeDirectory>/.m2/repository/. The package actually is in <homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/
I do not presume to understand Maven, but the two potential reasons I could imagine are:
it gets confused with : and / (i.e. UNIX style path seperator vs. whatever : means in Maven), or
if : and / are actually interpreted as the same, the path it searches for includes another subdirectory level jar that is not present in the real directory structure.
Detailed Explanation
I was trying to import a package locally in Maven (as the package is not deployed online). Various answers (e.g., this, and this) on stackoverflow recommend running mvn install on the jar containing the package like so (assuming the jar is in /usr/share/java, is version 1.0, etc. etc.):
mvn install:install-file -Dfile=/usr/share/java/<importedArtifactid>-1.0-SNAPSHOT.jar -DgroupId=<importedGroupid> -DartifactId=<importedArtifactid> -Dversion=1.0 -Dpackaging=JAR -DgeneratePom=true
and defining this in the current package's pom.xml by adding:
<repository>
<id>repository</id>
<url>file://${user.home}/.m2/repository/</url>
</repository>
The mvn install command deploys the package into <homeDirectory>/.m2/repository/. So far, this works fine:
<prompt> $ mvn install:install-file -Dfile=/usr/share/java/<importedArtifactid>-1.0-SNAPSHOT.jar -DgroupId=<importedGroupid> -DartifactId=<importedArtifactid> -Dversion=1.0 -Dpackaging=JAR -DgeneratePom=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building <currentDirectoryProject> 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # <currentDirectoryProjectArtifactid> ---
[INFO] Installing /usr/share/java/economicsl-1.0-SNAPSHOT.jar to <homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.JAR
[INFO] Installing /tmp/mvninstall256012398997457078.pom to <homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.489 s
[INFO] Finished at: 2017-05-11T19:11:12+01:00
[INFO] Final Memory: 9M/292M
[INFO] ------------------------------------------------------------------------
<prompt> $
The package also appears in <homeDirectory>/.m2/repository/
<prompt> $ ls `<homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/`
<importedArtifactid>-1.0.JAR <importedArtifactid>-1.0.jar.lastUpdated <importedArtifactid>-1.0.pom _remote.repositories
<prompt> $
However, building the project that attempts to import the package fails:
<prompt> $ mvn package -U
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building <currentDirectoryProject> 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: file://<homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.jar
Downloading: https://repo.maven.apache.org/maven2/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.730 s
[INFO] Finished at: 2017-05-12T17:59:43+01:00
[INFO] Final Memory: 13M/292M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project <currentDirectoryProjectArtifactid>: Could not resolve dependencies for project <currentDirectoryProjectGroupid>:<currentDirectoryProjectArtifactid>:jar:1.0-SNAPSHOT: Could not find artifact <importedGroupid>:<importedArtifactid>:jar:1.0 in repository (file://<homeDirectory>/.m2/repository/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
<prompt> $
If an absolute path to the jar in /usr/share/java is defined in the pom.xml, the project builds successfully with a warning about not using absolute paths, but execution fails as it does not find the package again this time.
Maven version is Apache Maven 3.3.9.
Placeholders
<currentDirectoryProject> The project that is supposed to import the other package. All terminal commands are executed from the root directory of this project (this is where its pom.xml resides).
<currentDirectoryProjectArtifactid> ArtifactID of the project that is supposed to import the other package.
<currentDirectoryProjectGroupid> GroupID of the project that is supposed to import the other package.
<importedArtifactid> ArtifactID of the project that is to be imported
<importedGroupid> GroupID of the project that is to be imported
<homeDirectory> the user's home directory, i.e. /home/<userName>
<prompt> terminal prompt
You have a file extension "JAR" in upper case and maven is looking "jar" in lower case. If your file system is case sensitive, then that's important.

"mvn install " A maven commend not installed a jar from local into maven repository

I am new to MAC. I need to install some jars from local to maven repository.
Steps I followed :-
Kept jars "monte-screen-recorder.jar" at my local and run the below command to install into Maven repository.
mvn install:install-file -Dfile="\Downloads\monte-screen-recorder.jar" -DgroupId="org.monte" -DartifactId="monte-screen-recorder" -Dversion=0.7.7 -Dpackaging="jar"
SUCCESS message is shown in terminal. But actual jar is not present in Maven repository.
INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) # test ---
[INFO] Installing /Users/admnistrator/Documents/workSpaceIOS/test-automation-library/imageClient.jar to /Users/admnistrator/.m2/repository/com/experitest/client/imageClient/1.0/imageClient-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.527s
[INFO] Finished at: Thu Nov 17 17:02:07 IST 2016
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
Please let me know where I am making a mistake .
[INFO] Installing /Users/admnistrator/Documents/workSpaceIOS/test-automation-library/imageClient.jar to /Users/admnistrator/.m2/repository/com/experitest/client/imageClient/1.0/imageClient-1.0.jar
Maven install the image client jar file in your local maven repo curently. So you must have write a wrong command.
Can you show the full log (command + maven in the same log) ?
Use this central repository instead:
<dependency>
<groupId>com.pojosontheweb</groupId>
<artifactId>monte-repack</artifactId>
<version>1.0.1</version>
</dependency>

Error in pom file after adding external jar to project

I have created my own jar file and I included it into my project by running:
mvn install:install-file -Dfile=/Users/vladioffe/git/evappcom/evappcom/evapcom-1.0.jar -DgroupId=com.evapp.code -DartifactId=evappcom -Dversion={1.0} -Dpackaging=jar
The build succeeded - here is the output:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EvApp_Server 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) # EvApp_Server ---
[INFO] Installing /Users/vladioffe/git/evappcom/evappcom/evappcom-1.0.jar to /Users/vladioffe/.m2/repository/com/evapp/code/evappcom/{1.0}/evappcom-{1.0}.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.557s
[INFO] Finished at: Tue Jan 21 14:46:32 IST 2014
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------
When I have added the dependency to the pom file I encountered an error, here is the dependency:
<dependency>
<groupId>com.evapp.code</groupId>
<artifactId>evappcom</artifactId>
<version>1.0</version>
</dependency>
And the error I see near the <dependency> tag is:
Missing artifact com.evapp.code:evappcom:jar:
1.0
I tried to:
Restart eclipse
Clean project
re-install jar
disable and enable Maven
Update Project
Thanks!
Version is not supposed to be in brackets:
-Dversion={1.0} // it must be -Dversion=1.0

Missing artifact in attempted build using Maven

I'm trying to build a project in Eclipse with Maven. However I get the error
Missing artifact net.sf.doodleproject:numerics4j:jar:1.3
Running
mvn install
I got
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - tahrirproject:tahrir:jar:0.0.1-SNAPSHOT
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
Downloading: http://repo2.maven.org/maven2/net/sf/doodleproject/numerics4j/1.3/numerics4j-1.3.pom
[INFO] Unable to find resource 'net.sf.doodleproject:numerics4j:pom:1.3' in repository repo2_maven_org (http://repo2.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/net/sf/doodleproject/numerics4j/1.3/numerics4j-1.3.pom
[INFO] Unable to find resource 'net.sf.doodleproject:numerics4j:pom:1.3' in repository central (http://repo1.maven.org/maven2)
[WARNING] Overriding profile: 'null' (source: pom) with new instance from source: pom
[WARNING] Overriding profile: 'null' (source: pom) with new instance from source: pom
[WARNING] Overriding profile: 'null' (source: pom) with new instance from source: pom
Downloading: http://repo2.maven.org/maven2/net/sf/doodleproject/numerics4j/1.3/numerics4j-1.3.jar
[INFO] Unable to find resource 'net.sf.doodleproject:numerics4j:jar:1.3' in repository repo2_maven_org (http://repo2.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/net/sf/doodleproject/numerics4j/1.3/numerics4j-1.3.jar
[INFO] Unable to find resource 'net.sf.doodleproject:numerics4j:jar:1.3' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) net.sf.doodleproject:numerics4j:jar:1.3
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=net.sf.doodleproject -DartifactId=numerics4j -Dversion=1.3 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=net.sf.doodleproject -DartifactId=numerics4j -Dversion=1.3 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) tahrirproject:tahrir:jar:0.0.1-SNAPSHOT
2) net.sf.doodleproject:numerics4j:jar:1.3
----------
1 required artifact is missing.
for artifact:
tahrirproject:tahrir:jar:0.0.1-SNAPSHOT
from the specified remote repositories:
repo2_maven_org (http://repo2.maven.org/maven2),
central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Mon Mar 26 21:17:33 IST 2012
[INFO] Final Memory: 12M/105M
[INFO] ------------------------------------------------------------------------
So it seems like it's trying to download from a central repository even though it's specified in the pom.xml file.
pom.xml is here
Change pom section to:
<repositories>
<repository>
<id>doodleproject-repo</id>
<name>DoodleProject Maven 2 Repository</name>
<url>http://doodleproject.sourceforge.net/maven2/release</url>
</repository>
<repository>
<id>repo2_maven_org</id>
<url>http://repo2.maven.org/maven2</url>
</repository>
</repositories>

mvn tomcat:run doesn't start Tomcat

I am trying to deploy and run my webapplication using maven and its tomcat plugin.
I have set it up in project's pom.xml, but when I'm calling it from command line:
mvn tomcat:run
all that I get is:
[root#ovz6022 trunk]# mvn -e tomcat:run
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.gotbrains.breeze:breeze:jar:1.0
[INFO] task-segment: [tomcat:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing tomcat:run
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/trunk/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [tomcat:run {execution: default-cli}]
[INFO] Skipping non-war project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24 seconds
[INFO] Finished at: Thu Jul 23 14:34:31 MDT 2009
[INFO] Final Memory: 7M/14M
[INFO] ------------------------------------------------------------------------
And that's all. Tomcat hasn't been launched but I don't see any errors here.
Does anybody knows what's happening?
As mentioned before, you should use war packaging. However, if you can't because you're using OSGI or some other reason, you can tell the Tomcat plugin to deploy anyway even if it isn't war packaging by using the ignorePackaging option:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<ignorePackaging>true</ignorePackaging>
The clue is in the line:
[INFO] Skipping non-war project
The tomcat:run goal is intended to work with war projects, I'm guessing yours is a jar project.
You need to change the packaging of your project to war, you may also need to provide some additional configuration for the war to actually do anything.
Note: I'd recommend having a separate war project to your jar projects, then adding the jars as dependencies to the war.
if you're using Roo, and haven't yet invoked the controller command then your configuration is not yet set to generate a WAR file.

Categories

Resources