Connector for maven deployment? - maven

I have created a working maven archetype for a Vaadin/Hibernate/Spring project. I am able to install this archetype to my local repository and use it to generate new maven projects.
Now I want to deploy the archetype to my companies internal repository, so it might be used by other developers. However, when I run mvn deploy I recieve the following error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:
maven-deploy-plugin:2.7:deploy (default-deploy) on project
vaadin-hibernate-archetype: Failed to deploy artifacts/metadata:
No connector available to access repository maven.planet-ic.de
(maven.planet-ic.de/planet-ic-releases) of type default using the
available factories WagonRepositoryConnectorFactory -> [Help 1]
What is the connector that I am missing?
EDIT: I am not asking for someone to solve my problem, just some insight as to what the 'connector' is.
Here is my pom.xml if it should be of interest:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>de.planetic.maven.archetype.vaadin</groupId>
<artifactId>vaadin-hibernate-archetype</artifactId>
<version>1.1.0</version>
<packaging>jar</packaging>
<inceptionYear>2013</inceptionYear>
<description>
This archetype generates a Vaadin application for use with Hibernate, and to be deployed to a Tomcat 7 server. It may also work with other Tomcat versions and other servers.
</description>
<developers>
<developer>
<name>Maximilian Friedersdorff</name>
<email>max.friedersdorff#planet-ic.de</email>
</developer>
</developers>
<scm>
<connection>scm:svn:http://subversion.planet-ic.de/internal/maven/archetype/pinnwand-webapp/tags/pinnwand-webapp-archetype-1.1.0</connection>
<developerConnection>scm:svn:http://subversion.planet-ic.de/internal/maven/archetype/pinnwand-webapp/tags/pinnwand-webapp-archetype-1.1.0</developerConnection>
<url>http://subversion.planet-ic.de/internal/maven/archetype/pinnwand-webapp/tags/pinnwand-webapp-archetype-1.1.0</url>
</scm>
<distributionManagement>
<repository>
<id>maven.planet-ic.de</id>
<name>planet-ic-releases</name>
<url>maven.planet-ic.de/planet-ic-releases</url>
</repository>
<snapshotRepository>
<id>maven.planet-ic.de</id>
<name>planet-ic-snapshots</name>
<url>http://maven.planet-ic.de/planet-ic-snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
</pluginManagement>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</extension>
</extensions>
</build>
</project>

Depending on the maven repository you are trying to deploy to there are various methods available to upload your artifacts.
These methods are implemented using Maven Wagon connectors for different transport protocols (e.g. ssh,dav etc.), this is the term you are looking for.
Apache Maven Guide to using Extensions gives you an introduction on how to add connectors to your setup.

In the following line:
<url>maven.planet-ic.de/planet-ic-releases</url>
You need to add prefix of "file://", because you need to tell maven you are using file connector not ftp, http or something else.
And you'd better to use relative path there. For example:
<url>file://${project.basedir}/maven.planet-ic.de/planet-ic-releases/</url>

<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</extension>
</extensions>
</build>
<distributionManagement>
<repository>
<id>remoteserver</id>
<name>MyCompany Repository</name>
<url>scp://server/path/repo</url>
</repository>

In case it helps others, adding the following to the pom.xml got it working for me
<build>
<extensions>
<extension>
<groupId>org.springframework.build</groupId>
<artifactId>aws-maven</artifactId>
<version>5.0.0.RELEASE</version>
</extension>
</extensions>
</build>

Related

How can I make maven deploy artifacts to the home directory on a remote server without specifying it?

I'm able to deploy my project to my remote server like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>3.0.0</version>
</extension>
</extensions>
</build>
<distributionManagement>
<repository>
<id>internal</id>
<url>scpexe://maven#myserver.com/home/maven</url>
</repository>
</distributionManagement>
</project>
But (as you can see) I'm forced to specify the home directory of the maven user on my server. Usually when I use scp I can simply use scp somefile.txt me#myserver.com: and the file is transferred to the home directory of the user on my server. But if I try something similar in the pom.xml:
<distributionManagement>
<repository>
<id>internal</id>
<url>scpexe://maven#myserver.com:</url>
</repository>
</distributionManagement>
I get this error message:
Execution default-deploy of goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy failed: For input string: "" -> [Help 1]
If I try this:
<distributionManagement>
<repository>
<id>internal</id>
<url>scpexe://maven#myserver.com</url>
</repository>
</distributionManagement>
then Maven tries creating the repo structure and deploying the artifact directly to the server root directory. So I get this error message:
Error executing command for transfer: Exit code 1 - mkdir: cannot create directory ‘//com’: Permission denied -> [Help 1]
Is there a way to specify the maven repository as residing in the users home directory without having to manually specify where the home directory is?
The Maven configuration file uses a different syntax. What your example shows is this
<url>scpexe://maven#myserver.com/home/maven</url>
So by extension what you want is this
<url>scpexe://maven#myserver.com/</url>
You could try using the $HOME environment variable like so
<distributionManagement>
<repository>
<id>internal</id>
<url>scpexe://maven#myserver.com:$HOME</url>
</repository>
</distributionManagement>
OR if that doesn't work maybe this might?
<distributionManagement>
<repository>
<id>internal</id>
<url>scpexe://maven#myserver.com:~</url>
</repository>
</distributionManagement>
Of course this is assuming you're running Linux as well.
you must add port number before $HOME
<url>scpexe://maven#myserver.com:22/$HOME</url>

Plugin.xml file is not found /generated for eclipse plugin project

I am developing one maven plugin which will be used to override default maven lifecycle.To resolve dependencies (eclipse and other) , I want to use tycho. So I cofigured maven project to convert it into eclipse-plugin-project.
Heres my POM
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.maven.plugin</groupId>
<artifactId>test-maven-plugin</artifactId>
<version>0.0.1</version>
<packaging>eclipse-plugin</packaging>
<name>test-maven-plugin</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<!-- add Mars repository to resolve dependencies -->
<repository>
<id>Mars</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/mars/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<!-- enable tycho build extension -->
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>0.23.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
Now , as my packaging type is 'eclipse-plugin' , it is not generating plugin.xml file while installing project (mvn install). If I do the packaging type as 'maven-plugin' , it generates plugin.xml , but it does resolve dependencies using tycho.
Any thoughts for combining both?

multi module maven release

i have a multi module maven project
the structure of the poms is workspace/parent , workspace/child1 ,workspace/child2
and in the svn repository i have one repository for all of them
when release:prepare executes , does not any problem, but when release:perform executes this error occurs
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-release-plugin:2.3.2:perform
(default-cli) on project veterans: Error executing Maven. Working
directory
"D:\java\myeclipse-workspace\veterans\target\checkout\veterans" does
not exist! -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to
execute goal
org.apache.maven.plugins:maven-release-plugin:2.3.2:perform
(default-cli) on project veterans: Error executing Maven.
i think the problem is the checkout from repository, because after checkout in the target folder we have trunk,tags,branches, but i think we must have parent,child1,child2
and other problem is, why when maven-release tags the snapshot, it tags the repository structure into svn repository tags?
after release:prepare we have trunk,branches,tags in svnrepository/tags/parent-1.0.0
this is my parent pom :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dpj</groupId>
<artifactId>veterans</artifactId>
<version>1.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<scm>
<connection>scm:svn:http://192.168.1.10:7075/svn/veterans/trunk</connection>
<developerConnection>scm:svn:http://192.168.1.10:7075/svn/veterans/trunk</developerConnection>
<url>http://192.168.1.10:7075/svn/veterans</url>
</scm>
<properties>
<jdk.version>1.7</jdk.version>
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
<packname>-${project.version}-FL-${maven.build.timestamp}</packname>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>../veterans-presentation</module>
<module>../veterans-service</module>
</modules>
<distributionManagement>
<repository>
<id>dpj-artifactory-releases</id>
<name>dpj-artifactory-releases</name>
<url>http://192.168.1.10:8082/artifactory/ext-release-local</url>
</repository>
<snapshotRepository>
<id>dpj-artifactory-snapshots</id>
<name>dpj-artifactory-snapshots</name>
<url>http://192.168.1.10:8082/artifactory/ext-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<tagBase>http://192.168.1.10:7075/svn/veterans/tags/</tagBase>
<tagNameFormat>#{project.artifactId}-#{project.version}</tagNameFormat>
</configuration>
</plugin>
</plugins>
</build>
</project>
i solved my issue by adding the project name in end of connection and developerConnection. as though
when the plugin wants to add to tag, it sets the checkout to parent folder. So i added the address of repository of projects with the name of folder after trunk.
<connection>scm:svn:http://reposotpry:7075/svn/veterans/trunk/veterans/</connection>
<developerConnection>scm:svn:http://reposotpry:7075/svn/veterans/trunk/veterans/</developerConnection>
and its fixed.

Maven SCM Plugin: Git SSH provider not found

I'm having a problem using the Maven SCM plugin with Git. I cannot get the plugin to work at all because it says the provider is not found. It gives me the following error when I run mvn scm:tag:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-scm-plugin:1.9:tag
(default-cli) on project hello-world-service-minimal: Cannot run tag command :
Can't load the scm provider. No such provider: 'git:ssh://git#git-eng.REDACTED.com'
. -> [Help 1]
My pom.xml looks like the following:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>net.REDACTED</groupId>
<artifactId>hello-world-service-minimal</artifactId>
<version>1.0.13</version>
<packaging>pom</packaging>
<name>hello-world-service</name>
<properties>
<lang.java.source>1.7</lang.java.source>
<lang.java.target>1.7</lang.java.target>
<dep.junit>4.11</dep.junit>
</properties>
<scm>
<developerConnection>scm:git:ssh://git#git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</developerConnection>
<url>scm:git:http://git-eng.REDACTED.com/PROJECT_NAME/hello-world-service-minimal/tree/master</url>
</scm>
<distributionManagement>
<repository>
<id>dev.release</id>
<url>file:${project.build.directory}/repository/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9</version>
<configuration>
<tag>${project.artifactId}-${project.version}</tag>
</configuration>
</plugin>
</plugins>
</build>
</project>
Anyone have any idea how to fix this? This is driving me crazy. I can't figure out what I am doing wrong at all.
The <url> tag is for a regular browsable URL. You need a <connection> tag (<connection> is for read access, <developerConnection> is for write access):
<scm>
<connection>scm:git:ssh://git#git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</connection>
<developerConnection>scm:git:ssh://git#git-eng.REDACTED.com|PROJECT_NAME/hello-world-service-minimal.git</developerConnection>
<url>http://git-eng.REDACTED.com/PROJECT_NAME/hello-world-service-minimal/tree/master</url>
</scm>
See the Maven POM Reference for more information.

Maven Multi-Module Project, Not Resolving Dependencies

I have a multi-module maven project that I can't get to compile. I have a Nexus repository sitting on my local network, and it is working (IntelliJ Idea is able to resolve my dependencies which reside only in that repository), and I am building through Jetbrains TeamCity. I am fairly certain that TeamCity is working since several other build configurations I have set up still work (using the same settings.xml). I am a bit of a loss for what could be causing the issue. Here are my pom files:
Parent pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.product.plugins</groupId>
<artifactId>plugin-parent</artifactId>
<version>1.2-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>product-wireless-plugin</module>
<module>product-paging-plugin</module>
</modules>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<pluginRepositories>
<pluginRepository>
<id>autoincrement-versions-maven-plugin</id>
<name>autoincrement-versions-maven-plugin</name>
<url>http://autoincrement-versions-maven-plugin.googlecode.com/svn/repo</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>autoincrement-versions-maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
<executions>
<execution>
<id>update-pom-versions</id>
<goals>
<goal>increment</goal>
<goal>commit</goal>
</goals>
<phase>compile</phase>
<configuration>
<autoIncrementVersion>true</autoIncrementVersion>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</project>
product-wireless pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>plugin-parent</artifactId>
<groupId>com.company.product.plugins</groupId>
<version>1.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.product.plugins</groupId>
<artifactId>product-wireless-plugin</artifactId>
<version>0.1.2</version>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.company.product</groupId>
<artifactId>product-common</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
</project>
product-paging pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>plugin-parent</artifactId>
<groupId>com.company.product.plugins</groupId>
<version>1.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.product.plugins</groupId>
<artifactId>product-paging-plugin</artifactId>
<version>0.1.2</version>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.192:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>com.company.product</groupId>
<artifactId>product-common</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
</project>
And the error I am getting is:
com.company.product.plugins:product-wireless-plugin
[13:54:16][com.company.product.plugins:product-wireless-plugin] Importing data from 'C:/TeamCity/buildAgent/work/40ac813105cf8bd7/product-wireless-plugin/target/surefire-reports/TEST-*.xml' with 'surefire' processor
[13:54:16][com.company.product.plugins:product-wireless-plugin] Surefire report watcher
[13:54:16][com.company.product.plugins:product-wireless-plugin] Downloading: repolocation/nexus/content/groups/public/com/company/product/product-parent/0.9.0/product-parent-0.9.0.pom
[13:54:16][com.company.product.plugins:product-wireless-plugin] Failed to execute goal on project product-wireless-plugin: Could not resolve dependencies for project com.company.product.plugins:product-wireless-plugin:jar:0.1.2: Failed to collect dependencies for [com.company.product:product-common:jar:0.9.1 (compile)]
I am at quite a loss while trying to debug this... does anyone have any suggestions?
There are several approaches / tools for troubleshooting this sort of problem.
For this "could not resolve dependencies" error, there is almost always a more detailed error message and/or stacktrace earlier in the build log. Maven logs are actually extremely verbose, to the point of having to search for the "root" error message several screens up from the build failure.
Re-run the build with the -X flag. Here is documentation of Maven command line switches
Another option is to use mvn dependency:tree to inspect the full graph of transitive dependencies. mvn help:effective-pom is another useful tool that prints out the pom.xml after considering your settings.xml, any active profiles, etc. Likewise mvn help:active-profiles
There are many problems in your multi-module build. The most important one is that you define a dependency:
<dependencies>
<dependency>
<groupId>com.company.product</groupId>
<artifactId>product-common</artifactId>
<version>0.9.1</version>
</dependency>
</dependencies>
which seemed either not be existing in a repository or you have not access to the repository which contains it or your download has failed based on whatever reason (can't guess!). Are you using a repository manager like Artifactory, Nexus, Archiva? If not i recommend to start using one.
Apart from that you are using different versions for parent and the module in wireless-module:
<parent>
<artifactId>plugin-parent</artifactId>
<groupId>com.company.product.plugins</groupId>
<version>1.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.product.plugins</groupId>
<artifactId>product-wireless-plugin</artifactId>
<version>0.1.2</version>
A multi module build should define the version only via the parent and not within the artifact which means the above should look like this:
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>plugin-parent</artifactId>
<groupId>com.company.product.plugins</groupId>
<version>1.2-SNAPSHOT</version>
</parent>
<groupId>com.company.product.plugins</groupId>
<artifactId>product-wireless-plugin</artifactId>
The module should not define a version itself, cause it will inherit it from the parent. Furthermore you can see that you have a module which defines a release version (1.2) whereas the parent defines a SNAPSHOT version. An application/modules which are under development should define a version which is a SNAPSHOT version which means a thing like 1.2-SNAPSHOTetc.
The same applies accordingly for the definition of the distributionManagement. This should be defined only once in the parent of the project.
BTW. If you have several project the best is to define a company parent which contains some default definitions like distributionManagement, pluginManagement, dependencyManagement etc.
Ok, I have solved the problem thanks to input from #noahlz. After utilizing the -X flag to debug my build, I was finding that the parent pom of "product-common" (product-parent) could not be found. After browsing my Sonatype Nexus repository, I discovered that my build system was only publishing new versions of the parent pom when new modules were added to it. So, even though my parent pom was on version 0.9.0, the repository had the latest version as 0.6.1. I suppose the "product-common" library was compiling correctly because it had access to the parent pom (with the 0.9.0 version number) at compile time. Either way, changing the parent pom version in "product-common" to point to the most recent in the repository resolved my build issues with my plugins.

Resources