For the past couple of hours, I have been unable to solve this issue. Note that I have tried looking for solutions with no avail.
Anyway, my issue is that I am unable to create a directory with the Maven Wagon plugin. Here is an snip of the error for reference.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project spigotsite:
Failed to deploy artifacts: Could not transfer artifact be.maximvdw:spigotsite:jar:0.0.12-20160523.053812-1 from/to public (ftp://***.***.***.***): Unable to create directory be -> [Help 1]
Snip of pom.xml
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>public</id>
<name>Repository</name>
<url>ftp://***.***.***.***</url>
</repository>
</distributionManagement>
Snip of settings.xml
<servers>
<server>
<id>public</id>
<username>***</username>
<password>***</password>
</server>
</servers>
I have verified that I am able to log onto the FTP and create a directory. I gave the FTP user full write permission to the folder as well as tested writing to the folder itself. I seem to be overlooking something and I appreciate if anyone could point out my mistake. Thank you in advance.
It worked for me:
POM.xml
<build>
...
<extensions>
<!-- Enabling the use of FTP -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>3.0.0</version>
</extension>
</extensions>
</build>
<distributionManagement>
<repository>
<id>ftp-repository</id>
<url>ftp://...myhost.../srv/ftp/</url> <!-- repository location -->
</repository>
</distributionManagement>
SETTINGS.xml
<servers>
<server>
<id>ftp-repository</id>
<username>myusername</username>
<password>mypassword</password>
<configuration>
<endpointChecking>false</endpointChecking>
</configuration>
</server>
...
</servers>
Related
I am trying to run a basic maven project through jenkins for artifact I am using myMavenRepo,I have done the configuration in pom.xml for myMavenRepo.write and myMavenRepo.read and added settings.xml file in .m2 folder below is the setting.xml
'''
<settings>
<servers>
<server>
<id>myMavenRepo.read</id>
<username>myMavenRepo</username>
<password>${yourHttpAuthReadPassword}</password>
</server>
<server>
<id>myMavenRepo.write</id>
<username>myMavenRepo</username>
<password>${yourHttpAuthWritePassword}</password>
</server>
</servers>
</settings>
'''
I have done below configuration for myMavenRepo.read and myMavenRepo.write in pom.xml
'''
<project>
...
<repositories>
<repository>
<id>myMavenRepo.read</id>
<url>${myMavenRepo.read.url}</url>
</repository>
</repositories>
...
</project>
'''
'''
<project>
...
<distributionManagement>
<repository>
<id>myMavenRepo.write</id>
<url>${myMavenRepo.write.url}</url>
</repository>
</distributionManagement>
...
</project>
'''
while running the job I am specifying "clean deploy" command but its giving error saying
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project demo: Failed to deploy artifacts: Could not transfer artifact com.example:demo:jar:0.0.1-20200502.130925-1 from/to myMavenRepo.write
Access denied to:
Please let me know how to fix 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>
I have setup a nexus server and afterwards I had the opinion to simple deploy an artefact to this nexus server. Therefore I created a simple Java project with this pom:
<project xmlns="...">
<modelVersion>4.0.0</modelVersion>
<groupId>MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
My settings file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<settings ...>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<name>Nexus Public Mirror</name>
<mirrorOf>central</mirrorOf>
<url>http://it-nexus.domain:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Then I have tried to deploy my artefact with:
mvn deploy
and I got this Error:
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-resources-plugin
:jar:2.6 in http://it-nexus.domain:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of
nexus has elapsed or updates are forced -> [Help 1]
Actually I don't know what I am doing wrong!?
You've got a few things wrong (well, everything really).
First, you can remove profiles and everything under it, along with activeProfiles, from your server.xml file. Next, you need to add a servers entry, containing a server with the id, 'nexus' (assuming you're uploading to the same nexus instance you're using to mirror central), along with a username and password of some sort.
Then you have to have a distributionManagement section in your pom, referencing the same server you've specified in the settings.xml file, and configure the maven-deploy plugin. Documentation for that can be found here. You will also need an scm section.
The actual error you talk about is probably because your nexus server isn't actually configured to proxy/mirror central. Oh, and you should use * as the argument to mirrorOf.
I am building a web project using spring framework and maven. I want to deploy it using ftp.
For this I have included the apache weagon :
<distributionManagement>
<repository>
<id>ftp-repository</id>
<url>ftp://ftp.xxxxx.com</url>
</repository>
</distributionManagement>
<build>
<!-- FTP TRANSFER -->
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-5</version>
</extension>
</extensions>
and I have also created a file settings.xml
<settings>
<servers>
<server>
<id>ftp-repository</id>
<username>user</username>
<password>pass</password>
</server>
</servers>
</settings>
But when I execute mvn deploy I get the following error:
Authentication failed, Password not specified for the repository ftp-repository.
Is this the correct way to deploy an app?
What else should I do to deploy it successfully?
For completeness sake, I have had this issue when i tried to connect to an sftp server using the default ftp 'wagon'. When I changed the artefactId to wagon-ssh (also see this link) the messages started to make more sense.
In other words; the error message is not very helpful in this particiular case.
I am trying to run the command, mvn release:perform, but I get this error:
Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy
(default-deploy) on project git-demo:
Deployment failed: repository element
was not specified in the POM inside
distributionManagement element or in
-DaltDeploymentRepository=id::layout::url
parameter
Here's my pom.xml file:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonatype.blog</groupId>
<artifactId>git-demo</artifactId>
<packaging>jar</packaging>
<version>1.1-SNAPSHOT</version>
<name>git-demo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<scm>
<connection>scm:git:git#github.com:Christian-Achilli-KP/git-demo.git</connection>
<url>scm:git:git#github.com:Christian-Achilli-KP/git-demo.git</url>
<developerConnection>scm:git:git#github.com:Christian-Achilli-KP/git-demo.git</developerConnection>
</scm>
<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>localSnap</id>
<name>RepositoryProxyRel</name>
<url>http://127.0.0.1:8080/nexus/content/repositories/releases/</url>
</repository>
<!-- use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>MylocalSnap</id>
<name>RepositoryProxySnap</name>
<url>http://127.0.0.1:8080/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
</project>
Actually I can see the
repository
declaration inside the
distributionManagent
tag.
Here's my settings.xml:
<settings>
<servers>
<server>
<id>localSnap</id>
<username>deployment</username>
<password>****</password>
</server>
<server>
<id>MylocalSnap</id>
<username>deployment</username>
<password>****</password>
</server>
<server>
<id>myserver</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://127.0.0.1:8080/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<properties>
<project.build.sourceEncoding>MacRoman</project.build.sourceEncoding>
<project.reporting.outputEncoding>MacRoman</project.reporting.outputEncoding>
</properties>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Any advice why it complains?
Review the pom.xml file inside of target/checkout/. Chances are, the pom.xml in your trunk or master branch does not have the distributionManagement tag.
I got the same message ("repository element was not specified in the POM inside distributionManagement element"). I checked /target/checkout/pom.xml and as per another answer and it really lacked <distributionManagement>.
It turned out that the problem was that <distributionManagement> was missing in pom.xml in my master branch (using git).
After cleaning up (mvn release:rollback, mvn clean, mvn release:clean, git tag -d v1.0.0) I run mvn release again and it worked.
You can also override the deployment repository on the command line:
-Darguments=-DaltDeploymentRepository=myreposid::default::http://my/url/releases
The ID of the two repos are both localSnap; that's probably not what you want and it might confuse Maven.
If that's not it: There might be more repository elements in your POM. Search the output of mvn help:effective-pom for repository to make sure the number and place of them is what you expect.
For me, this was something as simple as a missing version for my artifact - "1.1-SNAPSHOT"