When i build my project the jars for org.restlet.jee, as a dependency for apache-camel, are missing.
[WARNING] The POM for org.restlet.jee:org.restlet.ext.spring:jar:2.2.2 is missing, no dependency information available
So i added in Nexus a new proxy repository for http://maven.restlet.com/.
After adding there is an error during the discovery process:
Remote strategy prefix-file on M2Repository(id=maven-releases) detected invalid input, results discarded: Prefix file does not start with expected "## repository-prefixes/2.0" header, refusing to load the file.
Is there any solution how i can use the restlet repository with Nexus?
Edited: my pom.xml
<distributionManagement>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://xxx:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://xxx:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>deployment</serverId>
<nexusUrl>http://xxx:8081/nexus/</nexusUrl>
</configuration>
</plugin>
...
</plugins>
</build>
The prefix file message has to do with automatic routing. The site at maven.restlet.com doesn't support this feature. It's nothing to worry about though, see here for an explanation:
https://support.sonatype.com/entries/30645946-
Check to make sure the proxy repository you just added is a member of the group repository you've configured maven to use in your settings.xml file.
If that isn't the problem you can get information about this problem by using the technique described here:
https://support.sonatype.com/entries/21433982
I've had the same problem recently with restlet repo and proxying it through nexus. The problem is it doesn't accept proxying, you'll get this information by using techniques mentioned by rseddon.
To solve the problem you have to update your proxy repository configuration in nexus by setting a user agent in the optional http request settings to something being used by browsers, e.g. Mozilla/5.0 (X11; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0.
It should help.
Related
Is it possible to disable redeployment just from pom level via deployment plugin configuration?
Im trying to prevent redeployment of few artifacts in artifactory but dont want to set this globaly (i know it should be dole globaly, but im just a user of that artifactory and it is not up to me to decide).
Thats why i was wondering if it is posible to configure my artifacts poms to fail if deployment would in fact mean redeployment of non SNAPSHOT version.
Maven used: 3.6.1
There is no parameter for deploy:deploy to achieve this. There are two workarounds to prevent unintentional deploying at least:
1. deploy:deploy <skip>
<properties>
<skipDeploy>true</skipDeploy>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<skip>${skipDeploy}</skip>
</configuration>
</plugin>
</plugins>
</build>
Deploy with:
mvn deploy -DskipDeploy=false
2. Deploy to local TEMP by default, use profile to really deploy
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>local-dummy-repo</id>
<name>local dummy repository to prevent unintentional re-deploying</name>
<url>file://${env.TEMP}/maven-dummy-repo</url>
<layout>default</layout>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>deploy</id>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>repo</id>
<name>real repository</name>
<url>scheme://authority/path</url>
<layout>default</layout>
</repository>
</distributionManagement>
</profile>
</profiles>
Deploy with:
mvn deploy -Pdeploy
I am getting below error while using the plugin (sonar-maven-plugin 3.7.0.1746):
ERROR:
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project kcc-xbu-saprfc-services-sys-api: Unexpected internal error near index 1
I have added below in pom.xml file in respective sections:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</plugin>
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</dependency>
<repository>
<id>org.sonarsource.scanner.maven</id>
<name>sonar-maven-plugin</name>
<url>https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin</url>
<layout>default</layout>
</repository>
<pluginRepository>
<id>org.sonarsource.scanner.maven</id>
<name>sonar-maven-plugin</name>
<layout>default</layout>
<url>https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
Versions currently being used:
SonarQube version: 7.9.1
MULE_EE with version 4.2.2
JDK: 1.8.0_251 (mixed mode)
Maven Version : 3.173.0
However maven is getting executed from "C:\Program Files\Maven\apache-maven-3.6.2\bin\mvn.cmd".
I am executing the build using azure pipeline.
Please let me know how to resolve this issue. Thank you.
If you are going to submit your code for SonarQube platform, normally the pom file doesn't need to have those dependencies, instead of it you can decouple that in changing the settings.xml of the maven (if you have a dedicated server, it should be inside .m2 folder for Windows).
Maven's settings.xml should have this profile:
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
<properties>
<sonar.login>*your-user-here*</sonar.login>
<sonar.password>*your-pwd-here*</sonar.password>
<sonar.host.url>*url-of-your-sonar-platform*</sonar.host.url>
</properties>
</activation>
<profile>
After that, you can setup you pipeline to run the following command for your project:
mvn sonar:sonar
Good luck!
I'm trying to use Github's new Actions CI server to deploy packages to Github's new packages feature. It's not going well.
I think it's all set up correctly, but I get this error:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default-deploy) on project myproject: Failed to deploy artifacts: Could not
find artifact com.mycompany:myproject:pom:1.5 in github
(https://maven.pkg.github.com/mycompany/mycompany_repository) -> [Help 1]
This happens after it appears to upload that same pom successfully:
Uploading to github: https://maven.pkg.github.com/mycompany/mycompany_repository
/com/mycompany/myproject/1.5/myproject-1.5.pom
Progress (1): myproject-1.5.pom (4.1/6.1 kB)
Progress (1): myproject-1.5.pom (6.1 kB)
So, it looks to me like it is successfully uploading the pom, but then it fails to download the same pom a few seconds later.
I'm running the deploy with debug switches on: mvn -X -e deploy, but I can't see the exact http commands that Maven is sending to the server.
How do I debug this? Is there some Maven/Aether transport or something that will log what is going on under the covers?
In case anyone else lands here looking for a solution to OPs issue publishing to github, I had a similar issue and found that the URLs needed in settings.xml and pom.xml are inconsistent. In your settings.xml, the repo URL needs to be of the form https://maven.pkg.github.com/myuser/com/mycompany/mypackage, whereas in your project's pom file, it needs to be of the form https://maven.pkg.github.com/myuser/mypackage. So, for example, your settings.xml file in ~/.m2 would look something like this:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myuser/com/mycompany/mypackage</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>myuser</username>
<password>mypersonalaccesstoken</password>
</server>
</servers>
</settings>
Whereas the pom.xml file in the root of your project would need to look like this:
<project>
...
<groupId>org.mycompany</groupId>
<artifactId>mypackage</artifactId>
<version>1.0.0</version>
...
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/myuser/mypackage</url>
</repository>
</distributionManagement>
...
</project>
Other than this minor (but crucial) detail, my steps were the same as those outlined here. This allowed me to publish my Maven package to github package registry.
You can enable debug logging in the workflows.
Just add the secret:
ACTIONS_RUNNER_DEBUG
And set to true
See a similar answer here
I just spend 3 hours debugging why the guide on the page did not work for me. If you are following the guide posted here 1.
OWNER is your github username, and REPOSITORY is - you guessed it, the repo name.
Just remember to use lowercase in both OWNER and REPOSITORY.
When generating the personal access token, make sure the scopes for the token are the repo:* scopes as well as the more obvious write:packages and read:packages scopes (do not disable the repo scopes)
Otherwise it does just that
The following solution works for me:
Create a repository for packages e.g. maven-packages
Add <server></server> settings under <servers> in settings.xml: (do this per id used below)
<server>
<id>github</id>
<username>YOUR GITHUB USERNAME</username>
<password>A GITHUB TOKEN YOU CREATE FOR PUBLISHING PACKAGES</password>
</server>
Do NOT add <activeProfiles>, <profile> or <repositories> to settings.xml (only add <server> elements) as this is redundant for publishing and I am adding them to consuming projects' maven.xml so no need for duplication.
Add repository/ies to distributionManagement in pom.xml as follows:
<distributionManagement>
<snapshotRepository>
<id>github-snapshot</id>
<name>GitHub snapshot</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
<uniqueVersion>true</uniqueVersion>
</snapshotRepository>
<repository>
<id>github-release</id>
<name>GitHub release</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
<uniqueVersion>false</uniqueVersion>
</repository>
</distributionManagement>
Where OWNER is the GitHub account your project is / projects are under and maven-packages is the repositories you want to publish you project(s) to.
This enables using a dedicated repository for listing packages instead of publishing each project's package to a different (its own) repository, making consumption of multiple packages from your GitHub account easier, as you only need to configure a single repository for these packages:
<repositories>
<repository>
<id>github</id>
<name>GitHub</name>
<url>https://maven.pkg.github.com/OWNER/maven-packages/</url>
</repository>
</repositories>
Note: in the <servers> section of your settings.xml define a <server> per id used in repositories and distributionManagement e.g. github-snapshot, github-release, github in the above examples.
I want to deploy projects inside my CI/CD pipeline without using the distributionManagement block inside my pom which would look like this:
<distributionManagement>
<repository>
<id>central</id>
<name>x-releases</name>
<url>http://serverhostname/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>x-snapshots</name>
<url>serverhostname/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
I tried specifying the repositories via command line:
-DaltSnapshotDeploymentRepository=myserver::default::serverhostname/artifactory/libs-snapshot-local \
-DaltReleaseDeploymentRepository=myserver::default::serverhostname/artifactory/artifactory/libs-release-loca
But it fails with
Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
Specifying -DaltDeploymentRepository allows me to deploy an artifact to a repository, but I am not sure how to distringuish between SNAPSHOT and RELEASE anymore. I thought maven would be able to do this somehow automatically.
What commandline options to use to replace this distributionManagement block?
Check your maven-deploy-plugin version.
I was using version 2.7 and getting the same error but upgraded to 2.8.2 and the build completed successfully.
Here's the dependency:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
Summary: How do I copy some generated files into a webserver (eg IIS or Apache) directory using Maven?
Details:
I have a working application that builds in Maven. I've managed to get it building using the webstart-maven-plugin which produces all the needed files (.jar and .jnlp) in a directory target/jnlp. It also creates a zip file with them all in at target/foo-1.0.zip.
At the moment the webstart plugin does not have a deploy goal - the request for it has ended up on the FAQ (question 3). It may be implemented in future, but the suggestion for the time being is to use wagon-maven-plugin.
I've never used Wagon. To start with I'd like to just copy the files to a local directory served up by a webserver. Later I'd like to copy them remotely, probably using ftp. Can someone give an example to what I need to add to the pom.xml to get the local copy working (and hopefully an ftp example too?). I can't find it in the documentation. From reading I think I might also need the Wagon Maven File Provider but as this seems to have almost no documentation I'm not sure.
Wagon providers are only there to provide additional network protocol supports (such as FTP).
If you want to copy file to a webserver (local or distant) you can use Maven upload plugin :
...
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-upload-plugin</artifactId>
</plugin>
...
In parent pom :
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-upload-plugin</artifactId>
<version>1.1</version>
<configuration>
<resourceSrc>
${project.build.directory}/${project.build.finalName}.${project.packaging}
</resourceSrc>
<resourceDest>${jboss.deployDir}</resourceDest>
<serverId>${jboss.host}</serverId>
<url>${jboss.deployUrl}</url>
</configuration>
</plugin>
And to configure parameters in a smart way, I use maven profiles (in parent pom) :
<profiles>
<!-- local deployment -->
<profile>
<id>developpement</id>
<properties>
<jboss.host>localhost</jboss.host>
<jboss.deployDir>appli/jboss-4.0.4.GA/server/default/deploy/</jboss.deployDir>
<jboss.deployUrl>file://C:/</jboss.deployUrl>
</properties>
</profile>
<!-- distant deployment -->
<profile>
<id>validation</id>
<properties>
<jboss.host>ENV_val</jboss.host>
<jboss.deployDir>/home/envval/jboss/server/default/deploy/</jboss.deployDir>
<jboss.deployUrl>scp://PROJECT_LAN_HOST</jboss.deployUrl>
</properties>
</profile>
</profiles>
I've created an "ant launcher", to use it by clicking under Eclipse ant view :
<target name="copy war to JBoss local" description="Copy war to local JBoss">
<maven goal="upload:upload" options="-Pdeveloppement" />
</target>
But you can simply run it on a command line :
mvn upload:upload -Pdeveloppement
EDIT : By the way, for distant deployment, you may need a login password for scp to work. You have to add them to you Maven settings.xml file :
<settings>
...
<servers>
<server>
<id>ENV_val</id>
<username>login</username>
<password>password</password>
</server>
</servers>
...
</settings>
EDIT: You'll need to add the Atlassian repository:
<pluginRepositories>
<pluginRepository>
<id>Atlassian</id>
<url>https://maven.atlassian.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
EDIT: depending upong the remote protocol you'll have to add wagon extensions, see Uploading a directory using sftp with Maven
In the end I didn't use the Maven upload plugin - it seemed a bit limited and not part of the main maven distribution. I used the maven wagon plugin as suggested. Here is the simplest possible pom that I could make that worked. Hopefully others will find it useful, as I couldn't find anything similar easily.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<fromDir>${project.build.directory}/jnlp</fromDir>
<includes>*</includes>
<url>file://c:/inetpub/wwwroot</url>
<toDir>jnlp</toDir>
</configuration>
</plugin>
For remote distributions, you just change the URL type, and possibly add wagon extensions as necessary.