I would like to use my CVS as maven repository.. can anyone give suggestions?
There are 2 ways:
a) If you want to use it only in one project place a 'repo' directory at the toplevel. Than add jars in the maven convention (groupid in folders/artifactid/version/artifactif-version.jar).
To use this as a repository declare a file based repository in your pom.
<repositories>
<repository>
<id>some-repo</id>
<name>some-repo</name>
<url>file://${basedir}/repo</url>
<releases>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>
If you use this from a module pom you have to use a url relative to your module pom.
b) if you want to use it for several projects there are socalled 'wagons'. There is one for svn. These maven plugins let you use a SCM as repository. I don't know whether there is a cvs-wagon.
I would not put the dependencies in an SCM system like CVS for many reasons.
Each time you update a dependency in the pom, you need to manually add the corresponding dependency jar - in the exact same folder structure as expected by maven.
You need to worry about transitive dependencies and it can be overwhelming.
Since these dependencies do not change (except if they are SNAPSHOTS), SCM is an overkill for them. Each time there is a new version of the dependency, it needs to be in a different folder structure.
If you want to have control over the dependencies, you could create your own maven mirror using a repository manager. These store the dependencies typically using some content management libraries and can be backed up/archived.
On a related note, Maven Wagon SCM Provider can be used to publish projects to an SCM, but has not been tested with SCM based remote repository.
Related
For an Eclipse plugin project I need a p2 local repository to be automatically deployed with dependencies defined in the pom.
The best way (or the only way that really works) to do so is to use org.reficio plugin p2-maven-plugin.
Therefore I created a general project in Eclipse to prepare and hold the repository and a pom.xml that generates this repository.
When I execute the goal p2:site the repository is created successfully.
Now I am trying to make Eclipse with M2Eclipse to automatically execute that goal whenever the file pom.xml has ben changed (e.g. the user has added a new dependency or the file has been changed because an updated file has been downloaded from the SCM repository.
Is there a way to make M2Eclipse respectively it's Maven Project Builder to execute this phase automatically?
I am new to use maven to build projects, and IDE I am using is eclipse. For projects I built before, I never used attributes <repository> in POM file and they are running very well.
But when I read some projects in github, they always come with a POM file containing quite a lot of <repository>. After reading maven official website, I know that <repositories> are location to download jar files, but I am able to import all classes only specifying <dependencies> not <repositories>.
My question is why can I download libs without specify <repositories>? Is there a default value for repositories.
Yes there is the Maven Central repository, which is automatically bundled with your pom.xml / settings.xml if you don't specify one.
You usually specify a repo in your pom.xml when you need to access an artifact that your company produces internally, or when you want to reference snapshots or the third-party company you're working with hasn't given their artifacts to Central.
I have set up Nexus on and configured it so that it has a repository for my application and also the maven central repository exposed through a group called public and this groups is then added to my pom file:
<repositories>
<repository>
<id>repo1</id>
<name>my-repo</name>
<url>http://app1:8081/nexus/content/groups/public</url>
</repository>
I am able to browse the index both through eclipse maven repo browser and through a web browser but whenever I try and add a new dependency to the pom I get a missing dependency in my pom file and if I click on one of the jars in the maven repo browser in eclipse, even though it shows up in the tree I get an error message informing me that it could not resolve the artifact.
I want to be able to to disable the maven central mapping from within eclipse and ONLY go my Nexus server which has both maven central and my application specific repos supposedly exposed via the public group.
Can anyone help me with this configuration as currently I cannot resolve any new dependencies in any projects, I tried creating a new Spring MVC project and the only dependencies that resolved ok were the ones in my local maven respository.
Any help is appreciated.
The best way to enforce that only Nexus is used for artifact download is to set up a mirror in your settings.xml file. See here for information on how to do that:
http://books.sonatype.com/nexus-book/reference/maven-sect-single-group.html
During a non-tycho release, Maven checks if there are snapshot dependencies in the project being built.
Is there a way to do the same thing with an E4 project, built with Tycho?
p2 repositories don't have a (formal) notion of snapshot and non-snapshot artifacts. So technically you never have snapshot dependencies in a Tycho build, as long as you don't use SNAPSHOT artifacts from Maven repositories via pomDependencies=consider. The latter can be prevented in the same way as in Maven, i.e. by controlling the Maven repositories in your settings.xml (see e.g. this other answer).
But probably this isn't what you are looking for. You probably want to make sure that you don't reference artifacts which will disappear eventually and make your build non-reproducible. For this, you have to check the retention policy of the referenced p2 repositories and make sure that you only reference p2 repositories which are retained "forever". (Example: Retention policy of the Eclipse project p2 repositories.)
If the retention policies are not good enough (or you don't trust the providers to actually stick to them), you need to store copies of the referenced p2 repositories. You can for example download the p2 repositories as zip (or mirror the repository and zip it yourself), deploy it to a Nexus OSS and access it from your build via the Unzip Plugin. (Disclaimer: The Unzip Plugin is an offering of the Tycho project, of which I am a committer.)
Have a look at the Maven Settings References:
Repositories:
releases, snapshots: These are the policies for each type of artifact, Release or snapshot. With these two sets, a POM has the power to alter the policies for each type independent of the other within a single repository. For example, one may decide to enable only snapshot downloads, possibly for development purposes.
enabled: true or false for whether this repository is enabled for the respective type (releases or snapshots).
updatePolicy: This element specifies how often updates should attempt to occur. Maven will compare the local POM's timestamp (stored in a repository's maven-metadata file) to the remote. The choices are: always, daily (default), interval:X (where X is an integer in minutes) or never.
checksumPolicy: When Maven deploys files to the repository, it also deploys corresponding checksum files. Your options are to ignore, fail, or warn on missing or incorrect checksums.
layout: In the above description of repositories, it was mentioned that they all follow a common layout. This is mostly correct. Maven 2 has a default layout for its repositories; however, Maven 1.x had a different layout. Use this element to specify which if it is default or legacy.
I think the setting you're after could approximate the following.
<repository>
<id>my-repo</id>
<name>My Repo</name>
<url>http://my.repo.org</url>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
I'm using Maven2 and I can't seem to find any plugins in my repository. I'm getting errors like
repository metadata for:
'org.apache.maven.plugins' could not
be found on repository: myrepo
where myrepo is the name of my repository.
My question is how does Maven know where to find plugins? There's a reference in my error to metadata, what metadata is expected where and what format must it take? I've not had much luck so far looking for documentation...
(I'm not interested in the easy answer to use the central repo, I want to know why myrepo isn't working.)
Thanks!
In the root of each artifact (relative path to repository root [groupId]/[artifactId]), Maven expects to find a maven-metadata.xml file. It uses this file to determine the available versions, the latest version, and the released version.
For example common-logging's metadata from repo1 lists all the available versions and tells us the release version is 1.1.1 as of 28th Nov 2008.
<?xml version="1.0" encoding="UTF-8"?><metadata>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<versioning>
<release>1.1.1</release>
<versions>
<version>1.0</version>
<version>1.0.1</version>
<version>1.0.2</version>
<version>1.0.3</version>
<version>1.0.4</version>
<version>1.1</version>
<version>1.1.1</version>
</versions>
<lastUpdated>20071128191817</lastUpdated>
</versioning>
</metadata>
Maven will download the metadata for each remote repository to your local repository (with the name maven-metadata-[repo name].xml) so it can check the available versions without having to hit each repository each time. If you want to force Maven to refetch the metadata you can do so with the "-U" switch on the commandline.
If you have your own repository, it needs to publish this kind of metadata so Maven can determine if any of the versions are available is the right one. The simplest way to do this is to use a repository manager like Nexus or Artifactory which will both manage the metadata for you.