using a private github repository to host a private maven artifact - maven

Question title kind of explains it all. I've seen other questions referencing this but I think they are more geared towards the github repository being public. Using this configuration in the dependent project works when the repository is public:
<repositories>
<repository>
<id>company-core-mvn-repo</id>
<url>https://raw.github.com/company/company-core/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.company.core</groupId>
<artifactId>company-core</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
But not when I change the settings to private. I was hoping someone could eplicitly tell me that this isn't possible before I try another approach. It seems strange that the dependency has no issues publishing to github yet I can't find a configuration that will allow the dependent package to pull it down.

Related

3rdparty repository issues with maven pom.xml

I was looking for BIRT Dependency in the net. Package my code refers are
import org.eclipse.birt.chart.model.Chart;
import org.eclipse.birt.chart.model.attribute.Anchor;
It is using chartengineapi and below is the maven dependency entry for POM.
<!-- https://mvnrepository.com/artifact/org.eclipse.birt/chartengineapi -->
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>chartengineapi</artifactId>
<version>2.3.2</version>
</dependency>
Since it is part of other repository (https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/) it gives error in Pom.xml. Could any one help me to sort out this ?
added repository tag and resolved.
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
Add one more <repository></repository> and the give the new repo name and link. It worked for me though I am not sure whether this is a standard approach.

maven.elasticsearch.org returning a 404

We are running into an issue with our Maven dependency on the Elastic Search Libraries that our code depends on in order to build / compile.
The build process fetched these libraries at build time, however the maven elastic search repository seems to be off line all together.
http://maven.elasticsearch.org/ currently returns a 404 resulting in everything below it being unavailable which results in the build process failing.
Even the maven central repo for elastic shield returns 404's https://repo.maven.apache.org/maven2/org/elasticsearch/plugin/shield/
I have sent an email to support#elastic.co asking them to turn the Elastic Repo back on, any other idea why this repo would just go offline and how would I go about rectifying it? A local onsite mirror of central, but it feels like overkill for what we need it for.
From the official document here
The repository URL is : https://artifacts.elastic.co/maven/org/elasticsearch/plugin/shield/2.4.6/shield-2.4.6.jar
If you are using maven:
<project ...>
<repositories>
<!-- add the elasticsearch repo -->
<repository>
<id>elasticsearch-releases</id>
<url>https://artifacts.elastic.co/maven</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
...
</repositories>
...
<dependencies>
<!-- add the shield jar as a dependency -->
<dependency>
<groupId>org.elasticsearch.plugin</groupId>
<artifactId>shield</artifactId>
<version>2.4.6</version>
</dependency>
...
</dependencies>
...
</project>

Maven in-project repository doesn't work

This is my pom.xml file:
<project ...>
<repositories>
<repository>
<id>lib</id>
<name>lib</name>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>file://${project.basedir}/src/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>oracle.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
...
<dependencies>
...
</project>
But there is an error shown on the <dependency> tag: Missing artifact oracle.jdbc:ojdbc6:jar:11.2.0.4
The directory structure is this way:
test-project/
src/
lib/
oracle/
jdbc/
ojdbc6/
11.2.0.4/
ojdbc6-11.2.0.4.jar
Anything missing in the pom.xml file or wrong directory structure?
After searching for hours, eventually found the answer works for me.
Your settings.xml file declares a catch-all mirror. This takes effect over the local repository declaration in your pom file. Either remove the catch-all mirror, or try excluding the repository ID of your project repository from the mirroring:
Replace <mirror>*</mirror> with <mirror>*,!lib</mirror> in your MAVEN/conf/settings.xml
The best solution is start using a repository manager (Artifactory, Nexus, Archiva) and install the oracle jdbc driver there and than you can simply use it as a dependency.
If you really don't like to use a repository manager i can recommend the non-maven-jar-maven-plugin.
This is the solution on Windows but it's quite funny:
Replace
file://${project.basedir}/src/lib
by
file://${project.basedir}\src\lib
Reference:
See the comment in: http://blog.dub.podval.org/2010/01/maven-in-project-repository.html

How to add dojo-maven dependency?

I am currently trying to add dojo as maven dependency in a web project.
I found this link: http://mvnrepository.com/artifact/org.dojotoolkit/dojo-maven/1.8.0
where I copied the dependency node into my POM.
Next I searched where the dojo-maven artefact lies (in which repository). But I cannot find this information. I tried adding:
<repository>
<id>maven2repo</id>
<url>http://central.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
But when I build it sais: Could not find artifact org.dojotoolkit:dojo-maven:jar:1.8.0 in maven2repo (http://central.maven.org/maven2/)
The dojo-maven artefact can be found here http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22dojo-maven%22
Another place to search can be here http://download.dojotoolkit.org/ under the maven category.
Can someone give me a hint?
Do you have a dependency defined in your pom?
<dependency>
<groupId>org.dojotoolkit</groupId>
<artifactId>dojo</artifactId>
<version>1.8.0</version>
</dependency>
This will only add the "compiled" dojo code. It is not the full SDK (with the build utilities, etc). There is an outstanding ticket to publish the full SDK to the maven repository.
http://bugs.dojotoolkit.org/ticket/15120

Why is maven looking for artifact in the wrong repo?

I'm defining a dependency in pom.xml in a Maven 3 project. Dependency is as follows:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<scope>runtime</scope>
<version>2.2</version>
</dependency>
Repostory is described in pom as follows:
<repository>
<id>java.net</id>
<name>java.net</name>
<url>http://download.java.net/maven/2</url>
</repository>
Artifact is indeed present in the repository. It's easy to check. Despite that, Maven is trying to obtain the artifact from repo1.maven.org. What could be the reason of this? Maybe I make some crucial mistake in defining repository access? Other dependencies seem to do fine.
Plugin org.mortbay.jetty:maven-jetty-plugin:6.1.26 or one of its
dependencies could not be resolved: Could not find artifact
org.glassfish.web:el-impl:jar:2.2
in central (http://repo1.maven.org/maven2)
The repository that you have defined is used for dependencies, but not for plugins. Hence the error.
To address this, you need to define pluginRepositories:
<project>
<!-- ... -->
<pluginRepositories>
<pluginRepository>
<id>{repo.id}</id>
<url>{repo.url}</url>
</pluginRepository>
</pluginRepositories>
</project>
As to where you should specify - in pom.xml or settings.xml, read this SO post.
You need to check your maven settings.xml (Look into Maven folder: M2_HOME/conf).
The default repositories are defined there itself, and Maven central repository is taking precedence.
Define your repository in Maven's settings.xml like this:
<profiles>
<profile>
...
<repositories>
<repository>
<id>Java Net</id>
<name>Java Net</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
...
</pluginRepositories>
...
</profile>
You can maybe overwrite the default Maven central repository location with yours if you don't want to do much configuration.
Cheers!
In my case, the real root issue was that the repo required authentication. However for some reason maven decided that it would be much better to not tell me that, and to instead use the first repo in the <repositories> list, and throw the Could not find artifact error for that repo.
After moving the repo that contained the package so it was the first one in the <repositories> list, it started showing me a "permission denied" message. Once maven was setup for authentication with the repo in question, the issue went away.
I had a similar problem however, another developer had set up a mirror in that I simply copy-pasted into my settings.xml file. Modifying the mirrorOf property to only include specific repos did the trick.
In addition to the above mentioned answers, make sure your settings.xml is saved as an xml file not a text file i.e. its not saved settings.xml.txt.

Resources