I come to you today with an interesting challenge.
I have a maven+flexbuilder project that has a dependency on an external artifact.
This is specified with the following declaration:
<dependency>
<groupId>com.abc.commons</groupId>
<artifactId>commons-abc-client</artifactId>
<version>${commons.abc.version}</version>
<type>swc</type>
</dependency>
The commons-abc-client is deployed to an external releases repository, and is not available on the local environments for the AS developers.
The artifact is deployed to the remote repository using the followind command:
mvn clean source:jar javadoc:jar deploy
If I run
mvn eclipse:clean flexmojos:flexbuilder -DdownloadSources=true -DdownloadJavadocs=true
The dependency to commons-abc-client is properly generated (pointing to the downloaded-to-the-local-repo version) and it shows that the source is attached.
Trying to open any of the sources in the commons-abc-client throws an error. It seems as if it is looking the resources from inside the SWC and not in the attached jar.
Any ideas on work arounds?
Related
I am working with a maven project in eclipse which I have been testing using the built-in "run on server" tomcat option. When I try to do this, I get errors stating certain dependencies are unmet from an external jar I reference in the POM. However I have found if I add the jar via the DeploymentAssembly Tab I can run in eclipse without issues:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.company.user.server.UserDetailsAuthoritiesMapper#0'
The issue comes when I try to deploy on an actual tomcat instance. The Maven build runs fine, but when I start the servlet I get the same unmet dependency errors. This to me is indicating that the external jar is not being properly packaged into the war. What is the maven equivalent of adding the package via the DeploymentAssembly tab in eclipse? The entry in the POM.xml:
<dependency>
<groupId>com.company.webapp</groupId>
<artifactId>webapp-user</artifactId>
<version>106</version>
</dependency>
Thanks
You need to locate the maven info for the external jar. If you google the name of the jar and maven you often find a direct link to the block you need. For example if I want version 1.58 of the Bouncy castle jar Google "Maven BouncyCastle" you can find the artifact info. Add that info to your pom.xml as a new dependency in your block.
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.58</version>
</dependency>
After you rebuild, refresh maven in your IDE 1st after doing a clean, this will tell maven to pull down the jar and added it to your build.
You can also go to the repo directly and search:
Maven Repo: https://mvnrepository.com/
I am working in a Maven project (Java, using pom.xml files), where I need to use the FastMath library (part of the Apache commons math3 library).
The top level library on which I am working finds FastMath without problems. However, one of the dependencies (a local .jar that I installed so that it appears in the .m2/repository) also needs FastMath, but it gives the NoSuchMethodError message.
Installed the .jar as follows:
mvn install:install-file -Dfile=/home/me/Libraries/A.jar -DgroupId=x.y -DartifactId=y -Dversion=1.0 -Dpackaging=jar
Included it in the pom.xml file as follows:
<dependency>
<groupId>x.y</groupId>
<artifactId>y</artifactId>
<version>1.0</version>
</dependency>
It compiles without problems, the error only occurs when I attempt to run/debug.
Thanks, Michiel
This type of maven repository is not available in central repository also
.to resolve that one try to add manulaly dependencies to project http://mvnrepository.com/search?q=x.y
I have two projects both use maven. The project A is a utility library, and I use mvn install to my local maven repo. The project B is a web app, it has a dependency on A library.
when I run B project use mvn jetty:run it don't load a.jar in my local maven repository, but if I execute mvn package to package my web app, the a.jar will in its WEB-INF/lib.
I tried under maven 3.1 and maven 3.2, both have the problem.
I'm new to Maven 3 and have been using Maven 2 for many years, why can't this solution work as before?
Edit:
From the pom.xml:
<dependency>
<groupId>me.donnior</groupId>
<artifactId>rtl</artifactId>
<version>0.3</version>
</dependency>
Edit:
My problem is that my own installed A.jar can't be found when run mvn jetty:run, but others third-party jars that downloaded from network can be found in class path.
Updated:
I figure it out is a jetty plugin's dependency problem, can be closed now.
mvn jetty:run dont perform packaging Lifecycle.
It enables project without requiring that it is packaged. In this mode every component of the project is used from its origin location.
try to use jetty:deploy-warinstead as it perform mvn package lifecycle phase as well.
I want to add jpoller.jar as a maven dependency, so I edited my pom.xml file to include it:
<dependency>
<groupId>org.sadun</groupId>
<artifactId>jpoller</artifactId>
<version>1.5.2</version>
</dependency>
Now, as expected, when I compile from the command line I get an error because jpoller isn't in any of the repositories I have listed in my pom, nor could I find one for it. Although I could create a repository for it, I'd rather not at this point. Thus, I get the following error:
[INFO] Failed to resolve artifact.
Missing:
---------- 1) org.sadun:jpoller:jar:1.5.2
Try downloading the file manually
from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.sadun -DartifactId=jpoller -Dversion=1.5.2 -Dpackaging=jar -Dfile=/path/to/file
How can I do this from the M2Eclipse plugin on machines where the maven CLI isn't available?
How can I do this from the M2Eclipse plugin on machines where the maven CLI isn't available?
Well, simply do it from Eclipse. First, get that jpoller jar and save it somewhere on your file system. Then, in Eclipse, from the top bar, Run > Run Configurations... then right-click on Maven Build and configure the New_configuration freshly created:
Select an arbitrary Base directory
Fill the Goals with install:install-file
Add parameters for each required parameters, without the -D prefix (e.g. file as Parameter name and /path/to/file as Value and so on for groupId, artifactId,packaging and version).
And run this configuration. Or... just install Maven.
The install command automates the creation of a folder structure in ~/.m2 and pom.xml file for the dependency artifact. This can be done manually. OR You can simply copy the ~/.m2/{group}/{artifact} folder from a machine that does have mvn installed.
Edit: This tool will help you find public repositories for a given dependency.
Edit2: See http://maven.apache.org/guides/mini/guide-coping-with-sun-jars.html for an explination of the process of installing dependencies manually. Note that most sun jars are now available in the java.net repository http://download.java.net/maven/2/
I've just made a java project with maven:
mvn archetype:create -DgroupId=com.company -DartifactId=\
myproject -DarchetypeArtifactId=maven- archetype-quickstart
Then need to import a 3rd party jar, path is ~/Downloads/json-simple-1.1.1.jar, I tried the following commands:
mvn -e install:install-file -Dfile=~/Downloads/json_simple-1.1.1.jar\
-DgroupiId=org.json.simple - DartifactId=json_simple -Dversion=1.1.1 -Dpackaging=jar
but an error occoured:
[ERROR] BUILD ERROR
[INFO] Missing group, artifact, version, or packaging information
I'm using maven 2.2.1, java 1.6.0_35 and Ubuntu 11.10.
The dependency is already in maven central repository. Just the following dependency to the pom of your project and you are done:
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
You don't need to install json_simple locally. It is in Maven Central. Go to http://search.maven.org and search.
groupid: com.googlecode.json-simple
artifactid: json-simple
version 1.1.1
It is better to satisfy a dependency from Central rather than relying on one you installed locally. For a start, it will make it easier for other people to build your code.
As for the build problem, I suspect that you have made a mistake in the dependencies section of your project's "POM.xml" file.
Don't remember the exact syntax but you can di the following:
Add thus as a dependency in the pom file of the project you want to build
The build will fail as this jar is not part of the repo yet
But maven will also generate the command to install the jar in repo copy paste that, change the path the jar and execute.
This should solve the purpose.
But looks like this jar is already part of some repo.gGoogle it out might just need to add a new repo