Saturday, 7 September 2013

add custom jar to maven local repository

add custom jar to maven local repository

I want to add a custom jar to my Project. As I understand it the best way
to do that is to first add the jar to my local repository and then to add
it to my pom.xml.
So I tried the following:
mvn install:install-file
-Dfile=/home/martin/linuxhome/work/libMediator/libMediator
/dist/libMediator.jar -DgroupId=com.src.libMediator -DartifactId=libMediator
Dversion=1.0 -Dpackaging=jar -DgeneratePom=true
and then I added the following to my pom.xml:
...
<packaging>war</packaging>
...
<dependencies>
...
<dependency>
<groupId>com.src.libMediator</groupId>
<artifactId>libMediator</artifactId>
<version>1.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
Unfortunately I get the following error:
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building Reportgenerator 1.0.0-BUILD-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[WARNING] The POM for joda-time:joda-time-jsptags:jar:1.0.2 is missing, no
dependency information available
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @
Reportgenerator ---
[debug] execute contextualize
[INFO] Copying 26 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @
Reportgenerator ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8,
i.e. build is platform dependent!
[INFO] Compiling 21 source files to
/home/martin/linuxhome/Dropbox/c/Reportgenerator/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR]
/home/martin/linuxhome/Dropbox/c/Reportgenerator/src/main/resources/boilerplate/ReportIdentifizierer.java:[8,32]
package com.src.libMediator.prod does not exist
[ERROR]
/home/martin/linuxhome/Dropbox/c/Reportgenerator/src/main/resources/boilerplate/ReportIdentifizierer.java:[30,19]
cannot find symbol
symbol: variable C_ProdUtility
location: class boilerplate.ReportIdentifizierer
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2.116s
[INFO] Finished at: Sat Sep 07 15:30:50 CEST 2013
[INFO] Final Memory: 18M/169M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
(default-compile) on project Reportgenerator: Compilation failure:
Compilation failure:
[ERROR]
/home/martin/linuxhome/Dropbox/c/Reportgenerator/src/main/resources/boilerplate/ReportIdentifizierer.java:[8,32]
package com.src.libMediator.prod does not exist
[ERROR]
/home/martin/linuxhome/Dropbox/c/Reportgenerator/src/main/resources/boilerplate/ReportIdentifizierer.java:[30,19]
cannot find symbol
[ERROR] symbol: variable C_ProdUtility
[ERROR] location: class boilerplate.ReportIdentifizierer
[ERROR] -> [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/MojoFailureException
C_ProdUtility is a class from the jar I want to include,
boilerplate.ReportIdentifizierer is a class which belongs to the Project I
am working on.
I have tried to google the problem, but none of the solutions I found
worked. I could use the System Scope and give the location of the jar via
<systemPath>${project.basedir}/lib/libMediator.jar</systemPath>
. Then it compiles but this is discouraged and the jar isn't provided at
runtime. I haven't found out how to do that.
If I use
compile
The resulting .war gives the following error-message:
java.lang.ClassNotFoundException: com.src.libMediator.prod.C_ProdUtility
from [Module "deployment.Reportgenerator.war:main" from Service Module
Loader]
I verified that com.src.libMediator.prod.C_ProdUtility is in the
libMediator.jar

No comments:

Post a Comment