Unrecognized Tag 'repositores' - maven

upon doing a mvn clean I am greeted with an error
[WARNING] Unrecognised tag: 'repositories' (position: START_TAG seen ...tp://maven.apache.org/xsd/settings-1.0.0.xsd">\n\n <repositories>... #6:19) # /Users/geronimo.sanpascual/.m2/settings.xml, line 6, column 19
Here's my m2.
<?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">
<repositories>
<repository>
<id>artifactory</id>
<url>https://artifactory.sample.test/sample/sample</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mvnrepository</id>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<servers>
<server>
<id>artifactoryuser</id>
<username>user</username>
<password>password</password>
</server>
</servers>
</settings>
I tried adding it to a <profiles> </profiles tag but still didnt work.
Any help would be appreciated. thank you.
--Added the whole POM file--

According to http://maven.apache.org/xsd/settings-1.0.0.xsd you can't have a <repositories> tag directly in <settings>, you should include it into a <profile> like that
<settings ...>
<profiles>
<profile>
<id>some_profile_name</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>artifactory</id>
<url>https://artifactory.sample.test/sample/sample</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mvnrepository</id>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
...
</settings>

Related

Could not download maven-fail-safe-plugin. Giving me an error message

I have created a new maven project with serenity framework. I am getting this error in my new maven project
Plugin org.apache.maven.plugins:maven-failsafe-plugin:2.22.1 or one of
its dependencies could not be resolved: Failed to read artifact
descriptor for
org.apache.maven.plugins:maven-failsafe-plugin:jar:2.22.1: Could not
transfer artifact
org.apache.maven.plugins:maven-failsafe-plugin:pom:2.22.1 from/to
central (http://jcenter.bintray.com): Authorization failed for
http://jcenter.bintray.com/org/apache/maven/plugins/maven-failsafe-plugin/2.22.1/maven-failsafe-plugin-2.22.1.pom
403 Forbidden
You need change http to https
http://jcenter.bintray.com to https://jcenter.bintray.com
I found this way, just delete these line below in pom.xml and it's worked:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
In my case, I had mistakenly removed jcenter configurations from the ~/.m2/settings.xml while my organization specific repositores. After adding it started working.
<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<servers>
...
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bintray</activeProfile>
</activeProfiles>
</settings>

Jenkins maven release goes to lib-snapshot repository

I am having setup where Jenkins is used to release maven project to artifactory. I see everything is working fine what maven release do like incrementing pom versions, creating tag but it is not uploading to lib-release repo instead it is uploading it to lib-snapshot repo.
I verified my settings.xml and saw it uses different ids for snapshot and release repo. What else can I check to fix this issue?
This is my settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--<settings.version>1.0.1</settings.version>-->
<!--<settings.region>IL</settings.region>-->
<!--<settings.type>server</settings.type>-->
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<id>artifactory_server</id>
<username>deploy_user</username>
<password>xxxxxxxxxxxxxxxxxxx</password>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots />
<releases>
<enabled>false</enabled>
</releases>
<id>artifactory-snapshots</id>
<name>libs-snapshot</name>
<url>http://artifactory.example.com/artifactory/libs-snapshot</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>artifactory-release</id>
<name>libs-release</name>
<url>http://artifactory.example.com/artifactory/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>central</id>
<name>plugins-release</name>
<url>http://artifactory.example.com/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://artifactory.example.com/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
It's completely up to Maven and POM definitions.
By default every Jenkins run are threaten as Snapshots but you can control them by
Repositories with
<snapshots>
<enabled>false</enabled>
</snapshots>
And using maven-release-plugin https://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html

Maven Configuration issue - settings.xml

Few jars are taken from my repository successfully. This particular jar (failed, see below) needs to be from Maven central Repo but it is seeing to download it from my repo where this jar is not present. I feel that my configuration in settings.xml is wrong. My major doubt is in mirror configuration.
Could not find artifact org.springframework.boot:spring-boot-starter-parent:pom:1.4.0.RELEASE in my domain http://w3.maven.mydomain.com/nexus/content/repositories/domain)
<?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">
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers>
<server>
<id>myrepo</id>
<username>myname</username>
<password>****</password>
<configuration></configuration>
</server>
</servers>
<mirrors>
<mirror>
<id>maven2</id>
<name>maven2</name>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>maven</mirrorOf>
</mirror>
<mirror>
<id>myrepo</id>
<name>repo TPS</name>
<url>http://w3.maven.mydomain.com/nexus/content/repositories/domain</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles></profiles>
</settings>
Try adding below in your pom.xml
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

Project won't build when settings.xml exists

Following on from Unable to build maven project, pom.xml file not found, I'm finding that if settings.xml exists, the project fails to build. However I need settings.xml to tell maven how to find the Oracle ojdbc6.jar file.
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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>build_server</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://build_server:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://build_server:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://build_server:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://build_server:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
The pom.xml is quite large (649 lines) but if the above settings.xml does not exist, the project builds but then fails the unit tests as it can't connect to the Oracle DB. If the above settings.xml file does exist, the it can;t find artifacts in Artifactory that it does find if settings.xml doesn't exist.
The reposiories and distribution management section are:
<repositories>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://build_server:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://build_server:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://build_server:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://build_server:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
<pluginRepository>
<id>maven.oracle.com</id>
<name>oracle-maven-repo</name>
<url>https://maven.oracle.com</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>build_server</id>
<name>build_server-releases</name>
<url>http://build_server:8081/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>build_server</id>
<name>build_server-snapshots</name>
<url>http://build_server:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
I'm thoroughly confused and am hoping for some guidance.
build_server (not its real name) runs artifactory on port 8081 and teamcity on 8111.
Thanks
OK, so the problem turned out to be the ID's. I changed the ID's in the pom.xml in the distributionManagement section to match the ID's in the pluginRepositories section and now it works.
I hope this helps someone else.

Nexus group by SNAPSHOT

I have Nexus with builds repository. How I can group my versions on folders named snapshot-x.x ?
Repository have snapshot type. User deployment have all privileges.
I run maven as mvn versions:set -DnewVersion=$VERSION and mvn clean deploy -B -Pbuild -Dbuild.version=$VERSION
My settings.xml work only releases repo ;-(
<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>
</server>
</servers>
<profiles>
<profile>
<id>build</id>
<repositories>
<repository>
<id>nexus-repo</id>
<name>Nexus repo</name>
<url>http://<MY-HOST>:8081:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-repo</id>
<name>Nexus repo </name>
<url>http://<MY-HOST>:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<altDeploymentRepository>
-DaltDeploymentRepository=builds::default::http://deployment:<MY_PASS>#<MY-HOST>:8081/content/repositories/builds
</altDeploymentRepository>
</properties>
</profile>
</profiles>
</settings>
<activeProfiles>
<activeProfile>build</activeProfile>
</activeProfiles>
I'm not sure what you are asking for? A repository has a fixed format which comprises of groupId:artifactId:version ?
There you see com/soebes/examples/j2ee is the groupId: com.soebes.examples.j2eee and than artifactId: app plus the version 1.1.2-SNAPSHOT with the underlying versions for a single SNAPSHOT

Resources