I've added the following .jars as external jars to Libraries.
C:\Users\user\Downloads\common-lang3.jar\common-lang3.jar
C:\Users\user\Downloads\matlabcontrol\matlabcontrol-4.1.0.jar
However, during clean install of a Maven build in Eclipse, I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project com.webapp: Compilation failure: Compilation failure:
[ERROR] /C:/Users/user/workspace/GetTimeDistance/src/com/MatLabClass.java:[4,21] package matlabcontrol does not exist
[ERROR] /C:/Users/user/workspace/GetTimeDistance/src/com/MatLabClass.java:[7,40] package org.apache.commons.lang3.builder does not exist
The source of the jars in the library are pointing to the correct jars.
I am able to use the code in the jars in my own code.
When hoovering over the import, I get the following Note:
Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
Any idea's? I already updated the Maven project several times.
EDIT:
I've added:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.matlabcontrol</groupId>
<artifactId>matlabcontrol</artifactId>
<version>4.1.0</version>
</dependency>`
To the .pom file. This gives the following warning:
[WARNING] The POM for org.matlabcontrol:matlabcontrol:jar:4.1.0 is missing, no dependency information available.
When you run from maven, all the dependent jars will be referenced from maven repository only. It wont take any external libraries or jars. You define maven dependencies of the required jars in your pom.xml. If you want the local jars to be copied into your maven repository, below is the cmd mvn install:install-file -Dfile=your_local_path_of_jar -DgroupId=your_groupID -DartifactId=your_artifcat_id -Dversion=your_version -Dpackaging=jar
I assume you work with eclispe and added the external jars to the "Build path" of your Project properties? The "Build path" is used by the eclipse IDE to resolve classes within the workspace, and has no influence on which libraries are used when performing a maven build. Most likely, you missed to define commons-lang and matlabcontrol as dependencies in your pom.xml file...
Related
I'm a relative Maven novice and am having difficulties using a locally stored jar as a module within my IntelliJ project - a project I have taken from an online tutorial.
I've brought it into my .m2 folder using:
mvn install:install-file "-Dfile=C:/../resources/myshop-automatedtestscore 3.1.17-SNAPSHOT.jar" "-DpomFile=C:/../resources/myshop-automatedtestscore-3.1.17-SNAPSHOT.pom --Dsources=C:/../myshop-automatedtestscore-3.1.17-SNAPSHOT-sources.jar"
.jar is located at:
C:\Users\daveb\.m2\repository\com\myshop\automatedtests\myshop-automatedtestscore\3.1.7-SNAPSHOT\3.1.17-SNAPSHOT.jar
And I added the dependency in the main pom.xml as follows:
<dependency>
<groupId>com.myshop.automatedtests</groupId>
<artifactId>myshop-automatedtestscore</artifactId>
<version>3.1.17-SNAPSHOT</version>
</dependency>
When I go to Project Structure -> Libraries, I can see the Sources dependency jar file is there in grey so should be fine. However the core project seems to be unable to access the class versions of the file. In Target folder they remain .class but in External libraries they are .java
Apologies if this is a novice or obvious solution. I'm trying to resolve.
You have to install jar using below command -
mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion= -Dpackaging=
You have to give artifacts and other parameters so that you will be able to use in pom file using below code -
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>1.1.GA</version>
</dependency>
After that you have to complie your project so that this dependency will be added in your project.
mvn eclipse:eclipse
mvn clean install
You can press here to force refresh the plugins in Intelij.
Here you can check which repository you have and also which maven you have.
Click on preferences
Another option you have is to perform this :
mvn clean install -U
If your dependency is
<groupId>com.me.example</groupId>
<artifactId>my-example</artifactId>
<version>1.1.0</version>
Then your jar file would be my-example-1.1.0.jar and it will be under \.m2\repository\com\me\example\my-example\1.1.0\my-example-1.1.0.jar.
In your case, your jar file is myshop-automatedtestscore-3.1.17-SNAPSHOT.jar and it should be under
C:\Users\daveb.m2\repository\com\myshop\automatedtests\myshop-automatedtestscore\3.1.17-SNAPSHOT\myshop-automatedtestscore-3.1.17-SNAPSHOT.jar.
After this, do a Maven > Reimport from IntelliJ.
I have a Maven projects and i want to build a project with Maven to create excutable JAR
I can run the project successfully but
when i run Maven build... in eclipse with the command clean package i get(this is just a sample of the log but the rest of the log just repeat the same type of errors)
[INFO] Compiling 6 source files to C:\StrockMarketAnalyzer\USB\master\integ\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] C:\xxx\xxx\xxx\xxx-parent\xxx- integ\src\main\java\com/xxx/xxx/xxx\communicationInterface\IbfAdministrator.java:[22,48] error: package com.xxx/xxx/xxx.businessObject does not exist
[ERROR] C:\xxx\xxx\xxx-parent\xxx-integ\src\main\java\com\xxx\xxx\xxx\xxx\communicationInterface\IbfAdministrator.java:[23,48] error: package com.xxx.xxx.xxx.xxx.businessObject does not exist
and this is the pom.xml of the project i want to build.
<parent>
<groupId>com.xxx.xxx.xxx.xxx</groupId>
<artifactId>parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>integ</artifactId>
I am using packages from other projects that i created when i look to the JAR's in Maven dependency i can find the other projects with a folder icone and Inside them i can find there dependency but not there packages.
I hope there're enough information for you to know what's the problem
Try to run the parent project (with the same conf.)not the project it self.
Right klik project --> update project, wait for the Workbench to build then build using maven. This is a stopgap and not a permanent solution which i myself have not found yet.
You probably "run" the previous version of a program, without building it new.
You must write the dependencies and (their) repositories you use in pom.xml, the parent tag is strange to me.
Also, if you have dependency to another project you r working on clean and build it first.
I am working in Spring MVC, and was given an executable jar file with few classes and to add in my project.
I added that jar using build path as external jar.
Then I used a class in that jar file to call a method which returns a string.
I am getting error in maven install
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myproject: Compilation failure: Compilation failure:
[ERROR] com/mmf/controllers/myprojectController.java:[12,0] The import com.canonical.client.myClass cannot be resolved
[ERROR] com/mmf/controllers/myprojectController.java:[31,0] myClass cannot be resolved to a type
[ERROR] com/mmf/controllers/myprojectController.java:[31,0] myClass cannot be resolved to a type
Can anyone help me in this?
To add the external JAR file to your Maven project, you need to run the below command before you do mvn install.
mvn install:install-file -Dfile=<actual path for the intended jar file> -DgroupId=<group_id> -DartifactId=<artifactId> -Dversion=<version of jar file> -Dpackaging=<packaging>
For example,
mvn install:install-file -Dfile=E:\something.jar -DgroupId=someGroupId -DartifactId=someArtifactId -Dversion=someVersion -Dpackaging=jar
This step is required to be carried out only once. After you do this, the required JAR file will be added to the local maven repository and from next time onward, it will be used when you do mvn install.
It seems your jar is not available while building.
You can include the external jars in your build path as maven dependency with system
Eg :
<dependency>
<groupId>org.spring</groupId>
<artifactId>platform</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/platform-1.0.0.jar</systemPath>
</dependency>
Here is the documentation.
I have downloaded both of these projects, with bitcoinj being rebased to the correct v0.11.3 tag:
https://github.com/schildbach/bitcoin-wallet/
https://github.com/bitcoinj/bitcoinj
The bitcoin-wallet project gets bitcoinj 0.11.3 as a dependency on a maven repo and it works nicely. Then I changed it to use <scope>system</scope> to find the local bitcoinj .jar, which I built. Ever since I did this bitcoin-wallet complains with (with errors for each import and use of undefined symbols):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project wallet: Compilation failure: Compilation failure:
[ERROR] /.../bitcoin-wallet/wallet/src/de/schildbach/wallet/util/Crypto.java:[31,31] package org.spongycastle.crypto does not exist
This is odd because bitcoinj also imports org.spongycastle.crypto... and yet it builds correctly. I can't find any reference to spongycastle dependencies anywhere in the pom files for each. What is bitcoinj doing that bitcoin-wallet doesn't?
BitcoinJ, had bouncycastle hidden with another dependency:
<dependency>
<groupId>com.madgag</groupId>
<artifactId>sc-light-jdk15on</artifactId>
<version>1.47.0.2</version>
</dependency>
I want to use the commons-lang by maven,but apache repository isn't ,I down commons-lang-src publish in local repository ,but is warning.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test (default-test) on project commons-lang: There are test failures.
how to solve?
This is not the way to do it. As you can see in this maven mirror listing, the commons/lang sources are already available in all maven repositories that mirror central, so there is no need to build them yourself (BTW: if you build the project, you are installing the compiled binaries, not the sources, so even a success wouldn't have helped you).
Here's how to do it (Assuming you use eclipse):
If you use m2eclipse, just right-click the project and select Maven -> Download Sources
If you use the maven-eclipse-plugin see the page about adding sources to libs
If you don't use eclipse, I know there are similar plugins for NetBeans and IntelliJ Idea.
There are commons-lang binaries at repo1.maven.org.
http://repo1.maven.org/maven2/commons-lang/commons-lang/
Why don't use this?
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
Hope this will help you.
As an addition to #seanizer's answer, the command line solution is to use dependency:sources goal from the Maven Dependency Plugin:
dependency:sources tells Maven to resolve all dependencies and their source attachments, and displays the version.
So just run the following against your project on the command line
mvn dependency:sources
And maven will download the sources of dependencies, if they exist.