I´m using the mvn dependency:get to download some specific *.jar (latest Release Version) files on Linux Ubuntu.
I am using the following command:
mvn dependency:get -Dartifact=org.apache.httpcomponents:httpmime:RELEASE:jar -DrepoUrl=https://repo1.maven.org/maven2 -Ddest=/home/dev/workspace/"
The artifact is downloaded as expected, but only to the local maven repository and not to copied to the specified Location. I have also tried using
-Ddest=home/dev/workspace/
-Ddest=/home/dev/workspace
But there is no difference in the Result.
I know there is the possibility to use dependency:copy, but therefore i would need a pom.xml (which i don´t want to create only for the copy command).
Thanks for your help
I have given an examples. Please check.
mvn dependency:get -Dartifact=org.apache.maven:maven-core:2.2.1:jar:sources -DremoteRepositories=http://repo1.maven.apache.org/maven2 -Ddest=/home/dev/workspace/something.jar
You can also use dependency:copy as
Artifacts can also be resolved by specifying the classifier and optionally type. Type is only used with the classifier and defaults to java-sources. When the classifier is set, the list of dependencies is used as the base to resolve artifacts with the classifier and type.
For example:
mvn dependency:copy-dependencies -Dclassifier=sources
will try to find the sources for all dependencies and copy them.
For more data command line like:
mvn dependency:copy-dependencies [optional params]
Resource Link:
http://maven.apache.org/plugins/maven-dependency-plugin/usage.html
https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html
UPDATE:
use "-Ddest=path/to/my.jar"; otherwise, it is just copied to your local ~/.m2/repository (makes it look like nothing happened).
See http://maven.apache.org/plugins/maven-dependency-plugin/get-mojo.html#destination
example=>
mvn org.apache.maven.plugins:maven-dependency-plugin:2.5.1:get
-DremoteRepositories=repo.maven.apache.org
-Dartifact=org.apache.ant:ant:1.8.1
-Ddest=ant-1.8.1.jar
(result: ant-1.8.1.jar in current directory)
Related
I have a hundred repos in an organization and I am required to get the latest pom version for each repo. I have tried the current way of sh(returnStdout: true, script: "mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.${repoName} -Drevision=${env.BUILD_NUMBER} -q -DforceStdout) but since I am looping through multiple repos, i am unable to get the build number since the pipeline I'm running is not specific to one repo.
I have downloaded the Linux Test Project repository and compiled it. I now want to integrate it with the Alpine's binary image while compiling. A unix shell script that has Alpine specific commands will kick-in during compile time which adds these packages to the Alpine's binary. All the standard packages (like Python, Nginx and memcached) are getting integrated successfully by this script except LTP. The command used here is apk add <package name>. The same command doesn't work with the custom LTP's binary.
I tried n number of things like upgrading the apk package, supplying the entire LTP repository using --repository option, trying to manually generate an APKBUILD.tar.gz. Nothing works. Any help would be deeply appreciated.
Thanks in advance !
click here to see the image
i could not create maven project in eclipse IDE.
i am getting the error in the image and as well as mentioned below
Could not calculate build plan: Plugin
org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its
dependencies could not be resolved: Failed to read artifact descriptor
for org.apache.maven.plugins:maven-resources-plugin:jar:2.6 Plugin
org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its
dependencies could not be resolved: Failed to read artifact descriptor
for org.apache.maven.plugins:maven-resources-plugin:jar:2.6**
i have tried following:
deleted the folders and files under .m2/repositary and it did not work
windows->preferences->maven->user settings->and pointed the settings.xml to the downloaded apache maven 3.5.2 and it also did not work.
created the settings.xml under .m2/repositary ,it also did not work.
environment variable also set for maven(maven_home and m2_home) and java_home.
i have googled and tried all these but could not resolve this issue.
any help would be appreciated .
Thanks in advance.
First, make sure to use .m2/repository, not .m2/repositary
Check that your settings.xml is correctly set, with at least:
<mirror>
<id>Central</id>
<url>http://repo1.maven.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
Then check in a CMD (meaning outside) Eclipse, if:
M2_HOME and JAVA_HOME are also correctly set there
java -version does return the expected version
mvn -version does return the expected version
you can download the artifact:
For the last point, you actually can execute a mvn command, anywhere you want (no need for a pom.xml)
cd c:\
mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.2:get -Dartifact=org.apache.maven.plugins:maven-resources-plugin:2.6 -U
Name: My Software
Version: 1.0.5
Release: 1
Summary: This is my software
Not sure if anyone has tried this before or if it is easy, but:
A spec file has two unique indicators for its version:
Version (which specifies software version)
Release (which specifies the package's number - if you build an RPM, it's broken, and build another one, you up the 'Release' number.
I'm wondering if anyone has tried, or knows how, I could use the Jenkins $BUILD_NUMBER variable to dynamically change the Release number, thereby increasing the Release number every time a new successful build completes...?
It's been a long time... and thankfully I have no rpm based systems so I can't test this.
You can pass parameters to rpmbuild on the commandline
rpmbuild --define="version ${env.BUILD_NUMBER}"
It would be helpful to post snippets of the spec and the script you're using to build the rpm.
You don't want your build script editing the spec file, which I'm assuming it's pulling out down from some source control.
I've been using the Jenkins build number as the 'release' and packaging via fpm.
Couple fpm with some globals provided by Jenkins
# $BUILD_ID - The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
# $BUILD_NUMBER - The current build number, such as "153"
# $BUILD_TAG - String of jenkins-${JOB_NAME}-${BUILD_NUMBER}. Convenient to put into a resource file, a jar file, etc for easier identification.
There's some nebulous variables in the example command below, but $BUILD_NUMBER is what I'm using for the release here (fpm calls it iteration instead).
fpm_out=$(fpm -a all -n $real_pkg_name -v $version -t rpm -s dir --iteration $BUILD_NUMBER ./*)
In my Jenkins setup, I've decided to bypass the build number with regards to the RPM version numbering completely. Instead, I use a home-made script that generates and keeps track of the various releases that are being generated.
In my spec file:
Version: %{_iv_pkg_version}
Release: %{_iv_pkg_release}%{?dist}
And in the Jenkins build script:
# Just initialising some variables, and retrieving the release number.
package="$JOB_NAME"
# We use setuptools, so we can query the package version like so.
# Use other means to suit your needs.
pkg_version="$(python setup.py --version)"
pkg_release="$(rpm-release-number.py "$package" "$pkg_version")"
# Creating the src.rpm (ignore the spec file variables)
rpmbuild --define "_iv_pkg_version $pkg_version" \
--define "_iv_pkg_release $pkg_release" \
-bs "path/to/my/file.spec"
# Use mock to build the package in a clean chroot
mock -r epel-6-x86_64 --define "_iv_pkg_version $pkg_version" \
--define "_iv_pkg_release $pkg_release" \
"path/to/my/file.src.rpm"
rpm-release-number.py is a simple script that maintains a file-based database (in JSON format, for easy maintenance). It can handle being run at the same time, so no worries there, but it won't work if you have build slaves (as far as I can tell, I don't use them so can't test). You can find the source code and documentation here.
The result is that I get the following package versioning scheme:
# Build the same version 3 times
foo-1.1-1
foo-1.1-2
foo-1.1-3
# Increment the version number, and build twice
foo-1.2-1
foo-1.2-2
PS: Note that the Jenkins build script is just an example, the logic behind creating the rpmbuild directory structure and retrieving the .src.rpm and .spec file names is a bit more complicated.
Taking into account that spec file could be 3rd-party I prefer to do pre-build sed-patching of Release field:
sed -i 's/^Release:\(\s*\)\(.*\)$/Release:\1%{?_build_num:%{_build_num}.}%{expand:\2}/g' ./path/to/spec
rpmbuild --define '_build_num $BUILD_NUM' -ba ./path/to/spec
Here %{expand:...} macro is used to handle macro defined release numbers like ones in Mageia specs:
Release: %mkrel 1
Resulting field will be:
Release: %{?_build_num:%{_build_num}.}%{expand:%mkrel 1}
Conditional expansion of _build_num macro makes spec still usable for local build. I.e. if SRPM is also prepared by build system. But it could be reduced to:
sed -i 's/^Release:\(\s*\)\(.*\)$/Release:\1'$BUILD_NUM'.%{expand:\2}/g' ./path/to/spec
rpmbuild -ba ./path/to/spec
I have a libfoo-devel rpm that I can create, using the trick to override _topdir. Now I want to build a package "bar" which has a BuildRequires 'libfoo-devel". I can't seem to find the Right Way to get access to the contents of libfoo-devel without having to install it on the build host. How should I be doing it?
EDIT:
My build and target distros are both SuSE.
I prefer solutions that don't require mock, since I believe SuSE does not include it in its stock repo.
Subsequent EDIT:
I believe that the answer I seek is in the build package. Perhaps it's SuSE's answer to mock? Or it's the distributed version of the oBS service?
DESCRIPTION
build is a tool to build SuSE Linux
RPMs in a safe and clean way. build
will install a minimal SuSE Linux as
build system into some directory and
will chroot to this system to compile
the package. This way you don't risk
to corrupt your working system (due to
a broken spec file for example), even
if the package does not use BuildRoot.
build searches the spec file for a
BuildRequires: line; if such a line is
found, all the specified rpms are
installed. Otherwise a selection of
default packages are used. Note that
build doesn't automatically resolve
missing dependencies, so the specified
rpms have to be sufficient for the
build.
Note that if you really don't need libfoo-devel installed to build package bar the most sensible alternative would be to remove libfoo-devel from the BuildRequires directive (and maybe put the requirement where it belongs).
However, if you cannot do that for some reason, create a "development" rpm database. Basically it involves using rpm --initdb --root /path/to/fake/root. Then populate it with all of the "target packages" of your standard distro installation.
That's a lot of rpm --install --root /path/to/fake/root --justdb package-name.rpm commands, but maybe you can figure out a way to copy over your /var/lib/rpm/* database files and use those as a starting point. Once you have the alternative rpm database, you can fake the installation of the libfoo-devel package with a --justdb option. Then you'll be home free on the actual rpm build.
If neither mock nor the openSUSE Build Service are a viable choice then you will have to buckle down and install the package, either directly or in a chroot; the package provides files that the SRPM packager has decided are required to build, and hence is in the BuildRequires tag.