How to install maven dependency from Github packages? - github

I have created a maven dependency in Github package. I am trying to install this dependency in my another mule project.
settings.xml:
<server>
<id>github</id>
<username><owner></username>
<password><Token></password>
</server>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/<owner>/<repo-name></url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
Dependency from Github package:
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>hello-world-3</artifactId>
<version>1.0.11-SNAPSHOT</version>
</dependency>
I have created a hello world mule application and added the dependency in Pom.xml and ran mvn install on command prompt.
Getting this error:
D:\WorkSpace\test-package-dependency>mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.mycompany:test-package-dependency >----------------
[INFO] Building test-package-dependency 1.0.0-SNAPSHOT
[INFO] --------------------------[ mule-application ]--------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.845 s
[INFO] Finished at: 2021-11-19T17:21:57+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project test-package-dependency: Could not resolve dependencies for project com.mycompany:test-package-dependency:mule-application:1.0.0-SNAPSHOT: Failure to find com.mycompany:hello-world-3:jar:1.0.11-SNAPSHOT in https://maven.anypoint.mulesoft.com/api/v2/maven was cached in the local repository, resolution will not be reattempted until the update interval of anypoint-exchange-v2 has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I have searched online and did not get solution for my error. Also, tried jitpack. It didnt help too.

you have to define access repository url in pom.xml of your project where you wanted to access.
Just define like below,
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/<owner>/<repo-name></url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
or also try only with id and url
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/<owner>/<repo-name></url>
</repository>
</repositories>
Notes: Make sure you have given access to read or download the jar so that Maven can easily download for you while running maven phases.

Related

Eclipse Maven only downloads from HTTP central repository and fails

I'm trying to setup remote development for my raspberry pi using eclipse.
https://docs.deistercloud.com/content/Technology.50/Internet%20of%20Things/Raspberry%20PI.2/Eclipse.4.xml?embedded=true
When I run my ant build all the Maven downloads default to using these repositories:
HTTP response code: 501 for URL: http://repo1.maven.org/maven2/org/apache/maven/apache-maven/2.0.10/apache-maven-2.0.10.pom
I'm aware of the change to Maven that requires these downloads be from HTTPS sources and I've modified everywhere that I can think of to tell Maven to use the updated repositories to no avail. I included the below in my pom.xml:
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
I also followed all the steps here:
Requests to http://repo1.maven.org/maven2/ return a 501 HTTPS Required status and a body
No matter what, when I do the ant build, it forces downloads at the http location and fails.
Any advice?
The project is created in eclipse via new -> other -> maven -> org.apache.maven maven->quickstart

Error with Flyway Enterprise Edition Using Maven : Plugins could not be resolved

In my pom.xml I have
<dependencies>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway-maven-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-commandline</artifactId>
<version>${flyway-maven-plugin.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<repositories>
<repository>
<id>flyway-repo</id>
<url>https://repo.flywaydb.org/repo/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>flyway-repo</id>
<url>https://repo.flywaydb.org/repo/</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb.enterprise</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>${flyway-maven-plugin.version}</version>
<configuration>
<url>${flyway.url}</url>
<user>${flyway.user}</user>
</configuration>
</plugin>
</plugins>
</build>
In my settings.xml, I have added
<server>
<id>flyway-repo</id>
<username>${licenseKey}</username>
<password>flyway</password>
</server>
And I am running the command mvn compile flyway:info, I'm getting the below errors
[WARNING] The POM for org.flywaydb.enterprise:flyway-maven-plugin:jar:6.0.4 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.232 s
[INFO] Finished at: 2019-11-29T09:28:09+04:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.flywaydb.enterprise:flyway-maven-plugin:6.0.4 or one of its dependencies could not be resolved: Failure to find org.flywaydb.enterprise:flyway-maven-plugin:jar:6.0.4 in https://repo.flywaydb.org/repo/ was cached in the local repository, resolution will not be reattempted until the update interval of convergence-mirror has elapsed or updates are forced -> [Help 1]
[ERROR]
I have even set the flyway edition and flyway license key enviromental variables on my system. But I am still getting this error. Thanks to help !
If maven didn't resolve dependency, it will not try resolve it again until the update interval(24h usually)
Run maven with -U parameter to force dependency resolving, like mvn -U compile flyway:info or delete directory
/.m2/repository/org/flywaydb/enterprise/flyway-maven-plugin/6.0.4
Please look at
When maven says "resolution will not be reattempted until the update interval of MyRepo has elapsed", where is that interval specified?

Why do I see a heavily reduced public JBoss Maven repository in Eclipse?

As you can see in the picture at the end of this post only a few artifacts are available from the JBoss repository in Eclipse. But if you browse it online at https://repository.jboss.org/nexus/index.html#view-repositories;public-jboss~browsestorage there are hundreds. I have rebuilt and updated the index several times. I have checked "Full Index Enabled". I have changed the repository URL from https to http and back. I have searched the web of course but can't fix it. I'm not behind a proxy.
Here is some version information:
Ubuntu 10.10
Eclipse Indigo 3.7.2
Maven 3.0.4
The Maven central repository hosted at Apache is working fine, but the JBoss repository isn't. I have configured Maven with the settings.xml in my ~/.m2/ directory. Whenever I made changes, I have reloaded the settings.xml.
This is my 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">
<profiles>
<profile>
<id>jboss-public-repository</id>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>jboss-public-repository</activeProfile>
</activeProfiles>
</settings>
The Maven Repository Browser looks like this
Maven Repository Browser with very few artifacts in the JBoss repository

Why is Eclipse/Maven project not picking up the values from settings.xml?

I have saved the configuration at the bottom in c:\users\username\.m2\settings.xml but pom.xml created as part of Maven Project in Eclipse is not picking up the values. The effective POM still has
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
And what should be the http://ebr.springsource.com/respository equivalent of
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
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">
<repositories>
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
</repositories>
</settings>
you should add it to the home folder of the user who executes mvn command
By default your settings.xml is being looked up in:
The Maven install: $M2_HOME/conf/settings.xml
A user's install: ${user.home}/.m2/settings.xml

Maven error while downloading jboss-messaging

You could see below error that Im getting while compiling an EJB example that I'm trying to run with JBoss AS.
From error I could understand that repository URL specified is wrong. What I'm not getting is how can I find from where this URL is coming? Is this URL in any of the existing POM file in my repository/projects?
Also artifact version is "${version.jboss.messaging}". This is bit strange and I'm not able to find out where this version is specified?
Need some help here.
[ERROR] Failed to execute goal on project jboss-ejb3-examples-ch04-firstejb: Could not resolve dependencies for project org.jboss.ejb3.examples:jboss-ejb3-examples-ch04-firstejb:jar:1.1.0-SNAPSHOT: Failed to collect dependencies for [org.jboss.ejb3:jboss-ejb3-api:jar:3.1.0-Alpha1 (compile), junit:junit:jar:4.8 (compile), org.jboss.logging:jboss-logging-log4j:jar:2.0.6.GA (compile), org.jboss.logging:jboss-logging-spi:jar:2.0.5.GA (compile), org.jboss.arquillian.container:arquillian-openejb-embedded-3.1:jar:1.0.0.Alpha5 (test), org.jboss.arquillian:arquillian-junit:jar:1.0.0.Alpha5 (test), org.apache.openejb:openejb-core:jar:3.1.4 (test), javax.inject:javax.inject:jar:1 (test), org.jboss.jbossas:jboss-as-profileservice-client:pom:6.0.0.Final (compile), org.jboss.arquillian.container:arquillian-jbossas-remote-6:jar:1.0.0.Alpha5 (compile), org.jboss.jbossas:jboss-as-client:pom:6.0.0.M1 (compile)]:
Failed to read artifact descriptor for jboss.messaging:jboss-messaging:jar:${version.jboss.messaging}: Could not transfer artifact jboss.messaging:jboss-messaging:pom:${version.jboss.messaging} from/to repository.jboss.org (http://repository.jboss.org/maven2): Access denied to: http://repository.jboss.org/maven2/jboss/messaging/jboss-messaging/${version.jboss.messaging}/jboss-messaging-${version.jboss.messaging}.pom -> [Help 1]
This is my repository element in POM:
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>jboss-deprecated-public-repository-group</id>
<name>JBoss Deprecated Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
Point your JBoss Repository to: https://repository.jboss.org/nexus/content/groups/public-jboss/ instead of http://repository.jboss.com/maven2
<repository>
<id>JBoss Repo</id>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<name>JBoss Repo</name>
</repository>