Is it possible to add to run mvn as command with profile or Repository or other element and not from settings.xml ?
for example
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<localRepository>/home/vcap/app/.java-buildpack/tomcat/temp/maven_repo_6194547201292702175</localRepository>
<interactiveMode>false</interactiveMode>
<profiles>
<profile>
<repositories>
<repository>
<id>public.nexus</id>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</profile>
</profiles>
<activeProfiles>
<activeProfile>public.nexus</activeProfile>
</activeProfiles>
</settings>
Related
A few days ago I created a Github Package for a java library.
Now I wanted to add the dependency from Github Packages to another Maven Project, but I get the following error:
Could not transfer artifact io.geilehner:storyblok-java-sdk:pom:1.0.1 from/to github (https://maven.pkg.github.com/geilix10/): Transfer failed for https://maven.pkg.github.com/geilix10/io/geilehner/storyblok-java-sdk/1.0.1/storyblok-java-sdk-1.0.1.pom 400 Bad Request
My ~/.m2/settings.xml
<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">
<servers>
<server>
<id>github</id>
<username>geilix10</username>
<password>ghp__ PERSONAL_ACCESS_TOKEN....</password>
</server>
</servers>
</settings>
My pom.xml from the project where I want to add my package.
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/geilix10/</url>
</repository>
</repositories>
and the dependency itself:
<dependency>
<groupId>io.geilehner</groupId>
<artifactId>storyblok-java-sdk</artifactId>
<version>1.0.1</version>
</dependency>
I need the repository tag in the pom.xml because later on GitHub Actions should build this project and otherwise it would not find the package.
Link to the package: https://github.com/geilix10/storyblok-java-sdk/packages/716104?version=1.0.1
#Edit
After adjusting my settings.xml to (as suggested):
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<servers>
<server>
<id>github</id>
<username>geilix10</username>
<password>TOKEN</password>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/geilix10/*</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
And my pom.xml :
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/geilix10/storyblok-java-sdk/</url>
</repository>
</repositories>
<dependency>
<groupId>io.geilehner</groupId>
<artifactId>storyblok-java-sdk</artifactId>
<version>1.0.1</version>
</dependency>
And using the command to retrieve the package suggested by Allen D. I receive the following error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get (default-cli) on project regiolix: Couldn't download artifact: org.eclipse.aether.resolution.DependencyResolutionException: Failed to read artifact descriptor for io.geilehner:storyblok-java-sdk:jar:1.0.1: Could not transfer artifact io.geilehner:storyblok-java-sdk:pom:1.0.1 from/to github (https://maven.pkg.github.com/geilix10/): Failed to transfer file https://maven.pkg.github.com/geilix10/io/geilehner/storyblok-java-sdk/1.0.1/storyblok-java-sdk-1.0.1.pom with status code 400 -> [Help 1]
Explicitly add your repository to the URLs.
In your settings.xml:
<repositories>
...
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/geilix10/*</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
...
(Snapshots setting as you need...)
In you POM:
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/geilix10/storyblok-java-sdk/</url>
</repository>
</repositories>
Refer to https://github.com/allen-ball/ganymede for reference.
I was able to download your artifact with:
mvn dependency:get -DremoteRepositories=https://maven.pkg.github.com/geilix10/storyblok-java-sdk -Dartifact=io.geilehner:storyblok-java-sdk:1.0.1
after updating my settings.xml with:
<?xml version="1.0" encoding="UTF-8"?>
<settings ...>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
<servers>
<server>
<id>github</id>
<username>allen-ball</username>
<password>REDACTED</password>
</server>
...
</servers>
<profiles>
<profile>
<id>default</id>
...
<repositories>
...
<repository>
<id>github</id>
<name>GitHub Apache Maven Packages</name>
<url>https://maven.pkg.github.com/geilix10/*</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
...
</repositories>
...
</profile>
</profiles>
</settings>
I have a SpringBoot project that uses maven and IntelliJ IDEA Ultimate Edition (a build automation tool used primarily for Java projects)
I have this settings.xml for maven but when I do a mvn -U clean install, only goes the the first repository to find the files
<?xml version="1.0" encoding="UTF-8"?>
<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">
<localRepository>C:/Users/sandro/.m2</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>TeamNexus1</id>
<mirrorOf>*</mirrorOf>
<name>TeamNexus1</name>
<url>http://benficiones.com:8081/nexus/content/groups/public/</url>
</mirror>
<mirror>
<id>TeamNexus2</id>
<mirrorOf>*</mirrorOf>
<name>TeamNexus2</name>
<url>http://benficiones2.com:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>p1</id>
<repositories>
<repository>
<id>TeamNexus1</id>
<name>TeamNexus1</name>
<url>http://benficiones.com:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
<repository>
<id>TeamNexus2</id>
<name>TeamNexus2</name>
<url>http://benficiones2.com:8081/nexus/content/groups/public/</url>
<releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>p1</activeProfile>
</activeProfiles>
</settings>
You defined TeamNexus1 als <mirrorOf> everything. This means that any requests, to whatever repository they go, are redirected to TeamNexus1.
This is probably not what you want.
If you want to use the two repositories in addition to MavenCentral (which is implicitly configured), you can just remove the whole <mirrors> section.
I have server that use saml access
I want to write java application that get dependencies from this server.
I created settings.xml
<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">
<servers>
<server>
<id>repoID</id>
<username>myuser</username>
<password>mypaswrod</password>
</server>
</servers>
<profiles>
<profile>
<id>snapshot.build</id>
<repositories>
<repository>
<id>repoID</id>
<url>my-url</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>snapshot.build</activeProfile>
</activeProfiles>
</settings>
when I tried to run mvn clean install I got error from mvn because the SAML.
The error because it the mvn didn't succeed to download the relevant dependencies.
The error from MVN "no checkssum avaliable", when I tried to open the file that was download I got html error of SAML
Does MVN support SMAL access ?
I am following advice from the mvn project to use multiple artifact threads for parallel artifact resolution. This command seems to give me the desired result.
mvn -Dmaven.artifact.threads=10 dependency:resolve-plugins
Will this settings.xml automatically set maven.artifact.threads on every call to mvn?
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<profiles>
<profile>
<id>moreDependencyThreads</id>
<activation>
<property>
<name>maven.artifact.threads</name>
<value>10</value>
</property>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<activeProfiles>
<activeProfile>moreDependencyThreads</activeProfile>
</activeProfiles>
</settings>
You can set this property in your settings.xml file by changing it as follows:
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<profiles>
<profile>
<id>moreDependencyThreads</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.artifact.threads>10</maven.artifact.threads>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>moreDependencyThreads</activeProfile>
</activeProfiles>
</settings>
As it also specified in tutorial, you can make it permanent via:
export MAVEN_OPTS=-Dmaven.artifact.threads=10
If you call that it will be permanent for that session, if you add tis to your ~/.bash_profile it will be permanent for that user. Now on every call maven will work with these options.
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"