I am trying to implement a little service in Scala using Maven to manage dependencies and I would like to add webhdfs-java-client that I have found at https://github.com/wdavidw/webhdfs-java-client
I have added to pom.xml following code:
<dependency>
<groupId>org.zxs</groupId>
<artifactId>webhdfs-java-client</artifactId>
<version>0.0.0</version>
</dependency>
It does not work, as I have expected. Does anyone could give me an advice if there exists some catalog of maven repositories (something like pip for Python)? And what can I possibly do if I'll not find this library in the catalog? Is it possible to somehow add it to maven manually?
In maven world you can install this dependency locally and resolution will be done via local cache (the one that usually resides in ~/.m2). Steps are as simple as mvn clean install in that repo. Having said this, it wouldn't resolve problem for your users (transitive dependencies, you know), which is why you likely need to publish that dependency somewhere (or ask library author whether it's published somewhere).
SBT, which is scala's de-facto build tool allows you to depend on other sbt flavored projects simply by referencing their git repository, but sadly, maven has no such feature.
Related
I have a legacy project that I'd like to convert to a Maven project for dependency management.
The problem is, that I have one jar (fop-1.1.jar) that I had to edit. It differs from the one that is publicly available and I only have it locally. But I need it this way.
What I tried to do, following several similar how-to's, it to create a fake Maven repo inside the project (local repo is no good, because several people work on that project and the solution has to be self-contained on Git) and reference this repo from the pom.xml. Sounds like the way to go for me, but it doesn't work. Eclipse show the project repo grayed-out :(
What am I missing?
BTW: this is what I tried to follow: https://devcenter.heroku.com/articles/local-maven-dependencies
Let me suggest another way: When we need to "edit" a jar, we give it a special version number like 1.1-edited instead of 1.1.. Then we can easily upload it to our normal Maven repository and use it. Maven even makes sure that you do not accidentally load both versions in the same project because the edit is only in the version number.
I guess what you need is a private maven server(I guess it exists), and then execute command to deploy jar( before deploy, check your account has privileges)
mvn deploy:deploy-file -Dfile=${jarFilePath} -DgroupId=${groupID} -DartifactId=${artifactId} -Dversion=${version} -Durl=${privateServerURL} -Dpackaging=jar -DrepositoryId=${privateServerURLInYourMavenSettings.xml}
,
after deploy successfully, add maven dependency
<dependency>
<groupId>${groupID}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</dependency>
I am setting up a local repository using Apache Archiva. After setting up now I need to copy the libraries that got downloaded into my local maven repository into archiva. Currently I am manually copying it but it is very tedious process and I am planning to automate it using some scripts. Is there any better approach to do this?
I'm trying to write a plugin for this here which is able to copy jars and poms for all dependencies in all Configurations (including transitive dependencies). You might be interested in this code
Note: I've got a failing test here because I can't currently get the parent pom xml via the Gradle API's. I raised a feature request in Gradle here
There's a suggestion on the issue to use the IvyPot plugin... I haven't tried this myself but might be worth a shot.
I need to add the package "uk.ac.shef.wit.simmetrics.similaritymetrics"
to my maven project but I am not able to find any remote repository which contains it. I have to add it via dependency to the project, but not successful yet.
-I already added the jar file to the referenced library but in that wat I get the following error:
package uk.ac.shef.wit.simmetrics.similaritymetrics does not exist.
-Adding it through following dependency to the Pom.xml also does not help
<dependency>
<groupId>uk.ac.shef.wit</groupId>
<artifactId>simmetrics</artifactId>
version>1.6.2</version>
<scope>system</scope>
<systemPath>LocalPath\simmetrics-1.6.2.jar</systemPath>
</dependency>
Any help is appreciated!!
If this is a small project that you intend to only build locally or on a few machines then the simplest way is follow directions at the site below to add a 3rd party jar. Those instructions will help you install it in your local repository. You will need to do that for all machines that you intend to run the build on.
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
If you plan to run it on many machines then the best thing to do is to install the artifact to your own private repository. If that is the case then I suggest you create a project for it in version control. Then upload the file as part of that project.
I appear to be the current maintainer of Simmetrics. You can add this dependency to your pom file.
<dependency>
<groupId>com.github.mpkorstanje</groupId>
<artifactId>simmetrics-core</artifactId>
<version>4.0.1</version>
</dependency>
Simmetrics has been given a much needed serious overhaul since 1.6.2. You may have to adjust your code accordingly. For source code and documentation see https://github.com/Simmetrics/simmetrics
I have Java Maven Project with a folder lib with all jars that must be included in my project.
I don't know how I have to modify the POM to add all libraries. I want that Maven uses this libraries and I can use all in the project.
Lets be frank here: you are basically asking how to use Maven but then not use it at the same time. Maven is built around the fact that dependencies are managed from dependable repositories and then you come along and want to bypass that entire system by having local jars anyway as you would have in a project not managed through Maven - like one that is built with ANT.
The true clean solution to "not getting jars from a Maven repository" is to still get them from a repository - your own. Setup a local repository and put your third party dependencies there, then configure your Maven build to know about that local repository. If they are actually dependencies that exist in Maven central then you can setup your local repository to proxy them rather than manually installing them yourself.
http://maven.apache.org/repository-management.html
If you are using the release management features of Maven (or something like Hudson) then you should actually already have such a thing to stick your generated release artifacts into.
You have to know which libraries are you using. Imagine that you use in your project the joda-time library.
So you have to search your libraries (in this case joda-time) in maven repositories and add to your pom.xml like the following:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.7</version>
</dependency>
Here the Maven repository --> Maven Repo
I want to use Jmathplot.jar
I tried to put it as a dependency
<dependency>
<groupId>jmathplot</groupId>
<artifactId>jmathplot</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jmathplot.jar</systemPath>
</dependency>
but when installing I get this error:
Some problems were encountered while building the effective model for com.NResearch:dable-start-tRisk:jar:0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for jmathplot:jmathplot:jar should not point at files within the project directory, ${project.basedir}/lib/jmathplot.jar will be unresolvable by dependent projects # line 44, column 19
How can I get around this please?
EDIT1:
I cannot change Maven to include all dependent jars into a single jar. As this is uploaded to a web project.
"Dependent" is using your project, "dependency" is used by your project.
The real error here is that jmathplot.jar is in a folder that can really only reliably be found by your project. Even though your dependents know how to find your artifact in the local repository, they won't know where the sources are for your artifact, hence won't be able to find lib/jmathplot.jar. You can fix that by changing the systemPath to an absolute path. It can still be parametrized, but then please use properties rather than implicit properties (such as ${project.basedir}.
It'd be better to get rid of the systemPath dependency, by installing jmathplot into a company repository, so it can be used alike 'normal' artifacts. But that may not be a useful option if you have to distribute your artifact out of the reach of your company repository. It would even be better if jmathplot would just get deployed to the Maven central repository.
As a last resort you may choose to bundle the dependencies (not the dependents). You can do this:
Using the Maven Shade Plugin. It lets you choose which packages to include which may be useful to bundle only jmathplot (and not other dependencies).
Using the Maven Assembly Plugin. It has a predefined descriptor for "JAR with dependencies" which would fit your use case. You could create your own descriptor off of that example and set dependencySets.dependencySet.scope=system to only include the system dependencies that are giving you trouble.
Best way is to install your dependency on your local repository. To do this:
1) using project source, install to local repository using mvn install
2) if you don't have source code, install to local repository using this
hope it's help
nota: you are spamming around this question, do you ? (see here: JMathPlot what is the Maven dependency code please )