Martin Erlic
Martin Erlic

Reputation: 5667

Importing standalone jar into local maven repository

I'm using the following command to import a third-party jar, which is not available online, into my local Maven repository for purposes of building my project:

mvn install:install-file -Dfile=C:\Users\MNXE\plugins\myArtifactTest-generate\myArtifactTest-generate-plugin\lib\autoitx4java.jar -DgroupId=com.autoit.code -DartifactId=autoitx4java -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true

The dependency in my pom file for this jar looks like:

    <dependency>
        <groupId>com.autoit.code</groupId>
        <artifactId>autoitx4java</artifactId>
        <version>1.0.0</version>
    </dependency>

The following is the full stack trace of my error while attempting to install the Maven project. Regardless of my attempt to install the jar, or include the jar in my build path in Eclipse, nothing seems to work. I continue to get a compilation error:

C:\Users\MNXE\plugins\myArtifactTest-generate>mvn install -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] OO sample content project
[INFO] myArtifactTest-generate-plugin
[INFO] myArtifactTest-generate-cp
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OO sample content project 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ myArtifactTest
-generate ---
[INFO] Installing C:\Users\MNXE\plugins\myArtifactTest-generate\pom.xml to C:\Us
ers\MNXE\.m2\repository\myGroupTest-generate\myArtifactTest-generate\1.0.0\myArt
ifactTest-generate-1.0.0.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myArtifactTest-generate-plugin 1.0.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- oo-action-plugin-maven-plugin:10.20.8:generate-action-plugin (generat
e-contentpack-plugin) @ myArtifactTest-generate-plugin ---
[INFO]
[INFO] --- maven-plugin-plugin:2.9:descriptor (default-descriptor) @ myArtifactT
est-generate-plugin ---
[WARNING] Using platform encoding (Cp1250 actually) to read mojo metadata, i.e.
build is platform dependent!
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 4 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ myArtifact
Test-generate-plugin ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\MNXE\plugins\myArtifactTest-
generate\myArtifactTest-generate-plugin\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myArtifactTest-
generate-plugin ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1250, i.e. b
uild is platform dependent!
[INFO] Compiling 5 source files to C:\Users\MNXE\plugins\myArtifactTest-generate
\myArtifactTest-generate-plugin\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[9,20] package autoitx4java does not exis
t
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[123,38] cannot find symbol
  symbol:   class AutoItX
  location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[128,41] cannot find symbol
  symbol:   class AutoItX
  location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[133,39] cannot find symbol
  symbol:   class AutoItX
  location: class SampleActions
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] OO sample content project ......................... SUCCESS [0.817s]
[INFO] myArtifactTest-generate-plugin .................... FAILURE [6.999s]
[INFO] myArtifactTest-generate-cp ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.994s
[INFO] Finished at: Thu May 12 11:33:43 CEST 2016
[INFO] Final Memory: 17M/213M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project myArtifactTest-generate-plugin: Compilati
on failure: Compilation failure:
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[9,20] package autoitx4java does not exis
t
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[123,38] cannot find symbol
[ERROR] symbol:   class AutoItX
[ERROR] location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[128,41] cannot find symbol
[ERROR] symbol:   class AutoItX
[ERROR] location: class SampleActions
[ERROR] /C:/Users/MNXE/plugins/myArtifactTest-generate/myArtifactTest-generate-p
lugin/src/main/java/SampleActions.java:[133,39] cannot find symbol
[ERROR] symbol:   class AutoItX
[ERROR] location: class SampleActions
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on p
roject myArtifactTest-generate-plugin: Compilation failure
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compila
tion failure
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(Abstrac
tCompilerMojo.java:858)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.ja
va:129)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
        ... 19 more
[ERROR]
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :myArtifactTest-generate-plugin
C:\Users\MNXE\plugins\myArtifactTest-generate>

Upvotes: 0

Views: 1569

Answers (2)

Basil
Basil

Reputation: 2800

It is not exactly what you are trying to do, but will let you achieve same result. Instead of having troubles with local maven distribution libs repo (which is basically just a cache) you can use more general approach - install local Sonatype Nexus repository server and upload your artifacts into it. It is much easier to do than what you are trying. Besides you will get few other benefits:

  • you can use same Nexus repository across your team
  • you can create maven tasks to upload new versions of your custom artifacts
  • you will not need to configure maven distribution on every machine. Instead you will just configure your nexus repository address in pom.xml, just like any other maven repo.

From the point of Maven ideology what you need is your own Nexus repository. Otherwise if you want to create custom build process and use any custom libs, than your choice is Gradle, not Maven. Gradle gives you all maven benefits + much more freedom. For example in Gradle it is very easy to use local libs for project build together with any libs from Maven Central.

Upvotes: 1

Vijay
Vijay

Reputation: 552

I think you are missing version number in your jar file name. Your jar file name should be autoitx4java-1.0.0.jar

Upvotes: 1

Related Questions