I would like to use functional Java 3.0 in a maven project. I have been googling a little, but I can't find valid information to include the corresponsding 'dependency' in my pom.xml.
Someone mentioned that he would upload the artifacts to the scala-tools maven repository, but it does not seem like he followed-up on his announcement.
It does not even seem that earlier versions of functional Java are available from maven.
Does anyone have valid and recent information about this issue?
Thanks!
P.S.: Yes, I know I can download and manually include the .jar in my project, but this is only a workaround solution...
Version 3.0 is now in Maven Central: http://repo1.maven.org/maven2/org/functionaljava/functionaljava/3.0/
There doesn't seem to be any maven distribution. But here's a small shell script that will install the jar and the sources in your local repo.
Unpack the zip distribution and execute this script from inside the unpacked directory:
#!/bin/bash
# edit these to suit your needs
GROUPID=org.functionaljava
ARTIFACTID=fj
VERSION=3.0
mvn install:install-file -DgroupId=$GROUPID -DartifactId=$ARTIFACTID \
-Dversion=$VERSION -Dpackaging=jar -Dfile=functionaljava.jar
cd src/main
jar cf src.jar *
mvn install:install-file -DgroupId=$GROUPID -DartifactId=$ARTIFACTID \
-Dversion=$VERSION -Dpackaging=jar -Dclassifier=sources -Dfile=src.jar
rm src.jar
(Windows version would be very similar, probably just replace $this with %this%, maybe prepend CALL to the maven calls)
Fact is, I don't like to manually include .jars in repositories, because it is not a distributed solution.
I have copied the functional java code in a maven 'repository' project called 'externals' and it compiles fine. I can generate the artifacts and have no need to upload them manually anymore.
Related
I was previously on 1.6.x and mvn clean install builds wit no issues; end up with a 10mb jar and able to run all my code.
Now I want to upgrade to 1.10.x for the new lambda/apig/ddb support, I changed the version from 1.6.x to 1.10.x.
But after I build with mvn clean install, I see the jar is only 3kb, why is that? Has something changed with the way the AWS sdk works? At least from I've seen, one new way is you can be pick specific services rather than the whole sdk.
Edit:
The 3kb jar has the following:
pom.properties:
version=1.10.66
groupId=com.amazonaws
artifactId=aws-java-sdk
pom.xml, which lists all the aws sdk services
Have you uncompresssed the jar file and looked up what is in that folder? Based on the information in your question, I guess you have just got your own source files there but not the dependencies. If any, maven dependencies are usually located at META-INF\maven in jar. BTW, do you use maven plugins? For example, maven-jar-plugin only outputs your source code in jar while maven-assembly-plugin also outputs maven dependencies.
For a presentation purpose and installation handbook i like to run a tomcat-project directly with only maven installed.
I googled around an found:
a way to download the dependency directly my mvn dependency:get
a way to start the war by mvn tomcat7:run
Is there any way to have a short shell-command who download the dependency from the server, compile and start it?
Actually i got this:
mvn dependency:get tomcat7:run
-DgroupId=XXXXX
-DartifactId=hasty-tumbleweed
-Dversion=0.9.2-SNAPSHOT
-DrepoUrl=file://C:/Users/woodcraft.xenther-vladic/.m2/repository
But mvn still try to find the plugin from the official maven repository.
Any Idea?
Are you maybe missing this:
Caveat: will always check the central repository defined in the super pom
From the little information here, you make it look as if you're distributing files already (the repository stuff) so why not provide a POM as well, opening you up to doing whatever nifty Maven stuff you desire. Then you can do:
mvn install -f <path to your POM>
I am learning maven and trying to understand the order of things. As I understand, mvn clean install builds the repository with the default jars, where install produces a .zip that I will need later.
I want to use my custom jars which I call mvn install:install-file, but when I run this before install, I get some cannot find symbol errors. I am assuming my custom jars (which don't contain these classes) overwrites some default jars? I can't find these classes anywhere on my filesystem, so I am assuming they are already packaged in 1 of the default jars. How can I get around this?
Also, which order should I do things? All I want is the final .zip, that includes the custom jars?
mvn install -- builds and packages the source code and copies ( installs ) the artifact to your local repository which is $USER_HOME/.m2/repository
It's hard to say what's happening there without looking at the command you typed in, and the error trace that you received. That said, install-file is to copy an artifact to your local repo at appropriate hierarchy. It's nothing more than that. The correct syntax would be:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Usually, you just need to run install:install-file for all the custom dependencies once, and before you execute the mvn install.
If your custom jars have same coordinates -- artifactid, groupid, and version as some of the dependencies in your pom.xml and your custom jars do not have the classed that your source code uses -- well, you get the error.
refer: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Regarding to the maven-install-plugin website they mention as the following: -
install:install-file: is mostly used to install an externally created artifact into the local repository, along with its POM. In that case the project information can be taken from an optionally specified pomFile, but can also be given using command line parameters.
This means the artifact should be created before using this command. If you would like to deploy your fresh compiled code to the local repository, please just use the mvn clean install.
Please look at the Introduction to the Build Lifecycle for further information about the sequence and lifecycle. I hope this may help.
Regards,
Charlee Ch.
How do I download JAR during a build in Maven script?
Maven does not work like that. Here's the closest you'll get to my knowledge:
mvn dependency:get -DremoteRepositories=http://repo1.maven.org/maven2/ \
-DgroupId=junit -DartifactId=junit -Dversion=4.8.2 \
-Dtransitive=false
Note that all parameters except transitive are required.
Also note that Maven will download the jar to your local repository, and there's no sensible way (that I know of) to copy it to a local directory.
Reference:
dependency:get
Or since 3.1, simply as
mvn dependency:get -Dartifact=org.springframework:spring-instrument:3.2.3.RELEASE
Note: This answer is for downloading the jars directly from maven without any scripts [That is how Google directed me here]
Assuming mvn dependency is like this:
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.7</version>
</dependency>
Goto http://search.maven.org and search for g:"com.zaxxer" AND a:"HikariCP" AND v:"2.4.7" (simply searching for HikariCP also works. You may need to select the appropriate GroupId and Version from the results)
In the Search Results -> Download column, you should see jar javadoc.jar sources.jar available for direct download
You can use:
mvn dependency:copy -Dartifact=<group>:<artifact-name>:<version> -DoutputDirectory=/tmp/my_custom_dir
(Replace <values> with the ones of your case)
That's the full documentation of the goal: https://maven.apache.org/plugins/maven-dependency-plugin/copy-mojo.html
Note: the other "dependecy:get" way of doing this has been deprecated.
You can download Jar package to specific directory.
mvn dependency:get -Dartifact=org.riversun:random-forest-codegen:1.0.0 -Ddest=./
See How to use Maven pom to download jar files only. This worked really nicely for me.
My use case was that I wanted to download some of the dependency jars to deploy to a QA server, and was doing it manually (outside of the Maven build). I'm not sure exactly what your use case is.
This is what I do (2022 answer), go to https://mvnrepository.com/, search for your .jar and click on here:
Normally you don't use Maven for "just downloading", but for your build process. So normally, you do the following steps:
Define a new project by defining the archetype of your project and some needed properties.
Define as a dependency the library you want to use.
Run Maven with mvn compile
As a side effect, you will have downloaded the library to your local Maven repository. There are a lot of plugins to do something with dependencies, so have e.g. a look at the Maven Dependency plugin.
If you just want to download a JAR once from a maven mirror I suggest you could just do this manually:
For Maven 1:
http://mirrors.ibiblio.org/pub/mirrors/maven/
For Maven 2:
http://mirrors.ibiblio.org/pub/mirrors/maven2/
These are the repositories (a mirror anyway) that maven will get its JARs from - you can easily access them in the webbrowser of your choice and download the JARs etc. Just browse through the hierarchy (it looks like any Java packag hierarchy) until you find the artefact, then pick the right version and you're good.
For example version 3.6.6.Final of hibernate-core from group org.hibernate you'd find here:
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/hibernate/hibernate-core/3.6.6.Final/
You can setup a pom.xml to define your dependencies (the jars you want to copy). Then use the dependency:copy-dependencies goal to copy the jars to the desired location.
It's possible to download a JAR from a Gitlab Maven private repository. The URL is appearing when running some Maven command so it's a bit hacky but it's working for me.
Like this:
wget --header "PRIVATE-TOKEN: ${GITLAB_PRIVATE_TOKEN}" "https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/packages/maven/${MAVEN_PACKAGE_NAME}/${MAVEN_VERSION}/${JAR_FILE}"
Where,
GITLAB_PRIVATE_TOKEN is a Gitlab Token with right "api" (atm the others are not enough)
GITLAB_PROJECT_ID e.g. 1462237
MAVEN_PACKAGE_NAME e.g. com/bar/foo
MAVEN_VERSION e.g. 0.0.1
JAR_FILE e.g. foo-0.0.1.jar
Updated 2022 answer for command line - building on Ivan Carcamo's answer:
wget [the link that Ivan Carcamo points to in his screenshot]
Edit: This may download the thin jar for some repositories, so you may need to find a different link for the fat jar
Use the below code snip
result = subprocess.check_output('mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get \
-DgroupId=%s \
-DartifactId=%s \
-Dversion=%s \
-Dtransitive=false \
-DremoteRepositories={repos_string} \
-Dpackaging=jar \
-DoutputDirectory=%s' % (group_id,
artifact_id,
version_name,
des_path), shell=True)
logger.info("success download jar: %s" % each_version)
except Exception as e:
logger.error("Error in download jar : %s" % str(e))
All the jars are available directly in the maven central repository. You don't have to use "maven" if all you want is the jar.
https://repo.maven.apache.org/maven2/
If the pom dependency is
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.2</version>
</dependency>
You can download it from the corresponding directory structure by replacing the dots with forward slashses on the group id, artifact id, and version. I would navigate to the final folder to get the exact link of the jar.
https://repo.maven.apache.org/maven2/org/apache/poi/poi/5.2.2/poi-5.2.2.jar
As of December 12, 2022 the easiest way to download all dependencies including the jar file itself is to go to this link:
https://jar-download.com/online-maven-download-tool.php
And simply paste the Maven XML to the page and click download. God bless the person who built jar-download.com. :-)
This works for me, but it downloads only the latest version:
#! /bin/bash
set -eu
if [[ -z ${1:-} || -z ${2:-} ]]; then
printf 'Usage: %s group artifact\n' "$(basename "$0")" >&2
exit 1
fi
g="$1"
a="$2"
url='https://search.maven.org'
v="$(curl -s "$url/solrsearch/select?q=g:$g+AND+a:$a&core=gav&rows=20&wt=json" |
jq -r '.response.docs[0].v')"
curl -s -L -o "$a-$v.jar" "$url/remotecontent?filepath=${g//.//}/$a/$v/$a-$v.jar"
You need bash, curl and jq.
Example:
./maven-download net.sf.saxon Saxon-HE
Downloads Saxon-HE-11.4.jar today (2022-12-23).
I'm new to maven project.
I'm changing an ant project to maven project.
To install the 3rd party jar's in maven local repository, I used install command.
Its trying to download the resource jar.pom.
I don't have download access in my organization so the build failed for installtion.
After request i got the resouce jar and clean jar in my desktop(also i can get other necessary jar).
How to make maven to use these jar for the process and how to install the jar in local repository without internet acess.
I downloaded the jar and placed in local repository but it couldn't point the path and use those jars.
please let me know what steps i have follow to run maven install and other commands to build the project without internet access.
where should i placed the jar which i have downloaded by external way.
Please guide me for building and deploying the project.
Thanks in advance.
http://maven.40175.n5.nabble.com/Maven-installation-and-using-in-project-without-Internet-conncetion-tp4564443p4564443.html.
http://www.coderanch.com/t/544641/Jobs-Offered/careers/Maven-installation-project-without-Internet#2471141
I've posted same question in these link
You need an internet connection. Maven isn't initially self-sufficient. It needs to download a bunch of plugins along with their dependencies and the dependencies of your own project. And this really depends on what sort of settings you have for your projects. One set up will require one set of dependencies, another - a whole different one. You can't download artifacts from the Maven Central manually and then install them locally one by one. Simply put, that sounds stupid.
I understand that you're coming from the Ant world where Ant has everything it needs on the local file system. However, Maven relies on the fact that it will have a central repository (either Maven Central, or your own repository - Nexus, Artifactory, etc.) from which to download the plugins and dependencies it needs. There is no point in you migrating to Maven, unless you'll be allowed access to the Central Maven Repository.
Yes, indeed, you can run Maven offline and you can have Maven produce a local repository for you to use when you are in offline mode. However, what you're trying to do is against Maven's principles.
If your company won't allow access to Maven Central, just stick to Ant. Your effort will be a waste of your company's and, ultimately, your own time.
In fact the maven strenght is mainly in the internet accessible repositories and automatic dependency management. But it's possible to use this tool to build your project if you have all dependencies required for your project in your local repository. Then you may use -o option for offline mode and maven will not try to download updated artefact versions.
To get the artifacts into you local repository you have several options:
1) connect to the internet once and mvn build the project (this will download all required dependencies)
2) install dependencies as jar to the local repository manualy (using appropriate mvn command)
I think the questioner is looking for -o or --offline option for mvn. This is a command line option and can be provided while executing.
I think you can setup your repo correctly and execute the mvn goals once when you are connected to internet and use the -o option for later executions .
Hope this helps.
~Abhay
You can configure maven to run in offline mode. Add this entry to your settings.xml
<offline>true</offline>
See here for further information:
http://maven.apache.org/settings.html
Before you can use offline mode, you have to install all necessary third party jars to your local maven repository.
mvn install:install-file
-Dfile=filename.jar
-DgroupId=com.stackoverflow
-DartifactId=artifact
-Dversion=1.0.0
-Dpackaging=jar
-DcreateChecksum=true
-DgeneratePom=true
It's much easier to get those jars in your local repository using an internet connection and online mode.
It's possible to install these resource jars in your local maven repo using install-file. This will make the available to the build. You'll have to do this for each individually, but once that's done you won't have to do anything special.
To be clear, maven puts everything in your local repository, both the jar you're building with this project and the various library jars. Because your system cannot be connected to the internet to maven can populate the local repo with your libraries, you'll have to use this manual approach.
Edit: You should be able to run install-file anywhere. When you do, you'll need to provide the groupId, artifactId, version, and packaging using the command line options. If you already have a POM file for the library, you can provide that instead via -DpomFile=your-pom.xml.
This question has some useful info: How to manually install an artifact in Maven 2?