How to import Apache Flink SNAPSHOT artifacts? - java

I want to add the documents of Gelly to my project, but it gives me this error:
Sources not found for: org.apache.flink:flink-gelly_2.10:1.2-SNAPSHOT
This is in my pom.xml
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-gelly_2.10</artifactId>
<version>1.2-SNAPSHOT</version>
</dependency>
I tried looking for a different version of gelly to solve this issue but couldn't find any. is there any other way to get the documentation?

Apache publishes SNAPSHOT artifacts only to a dedicated Maven repository. Note that these artifacts are only meant for development purposes. They are not part of an official Apache Flink release!
You have to add the following repository configuration to your pom.xml to receive SNAPSHOT artifacts:
<repositories>
<repository>
<id>apache.snapshots</id>
<name>Apache Development Snapshot Repository</name>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
Alternatively, you can download the latest Flink code and build it on your local machine.

Related

How to consume a jfrog artifactory in a maven project

I created a sample project A and pushed it to my jfrog artifactory. Now, I want to use this in another maven project B.
To achieve this, I added this dependency declaration (copied from jfrog) in B's pom.xml:
<dependencies>
<dependency>
<groupId>com.testartifactory.example</groupId>
<artifactId>testartifactory</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>testartifactory</id>
<name>com.testartifactory.example</name>
<url>https://myjfrogurl/artifactory/libs-release-local/com/testartifactory/example/testartifactory/</url>
</repository>
</repositories>
But when I import this import com.testartifactory.example;, I get error that package com.testartifactory does not exist.
Even though I can see the project downloaded in repositories under .m2 folder:
Here is how my project A is structured:
I am new to this so I may be doing something wrong and would appreciate any help.
The repository URL should correspond to the repository in JFrog Artifactory. In your case: https://myjfrogurl/artifactory/libs-release-local
In the pom.xml:
<repositories>
<repository>
<id>testartifactory</id>
<name>com.testartifactory.example</name>
<url>https://myjfrogurl/artifactory/libs-release-local</url>
</repository>
</repositories>
Other options to use Artifactory for Maven builds are to use the Artifactory Maven plugin or the JFrog CLI. With these integrations, you'll get some more benefits such as build-info, Xray scanning, better performance and more.
Read more about Maven and Artifactory:
Maven Repositories in JFrog Artifactory
QuickStart Guide: Maven and Gradle
Running Maven Builds using the JFrog CLI

How to upload maven plugin to Github packages?

Consider I have a maven plugin project and I want to publish it to Github's public maven repository called "Github Packages". I've done everything by instruction and for normal projects everything works fine out of the box. But for maven plugin projects with packaging=maven-plugin the instruction doesn't work.
In build log I see something like this:
[WARNING] Could not transfer metadata repo-name/maven-metadata.xml
from/to github (https://maven.pkg.github.com/user-name/repo-name):
Failed to transfer file:
https://maven.pkg.github.com/user-name/repo-name/group-id/maven-metadata.xml.
Return code is: 422 , ReasonPhrase:Unprocessable Entity.
It seems the maven deploy plugin needs maven-metadata.xml in the group-id's root, but can't find it and no one puts it there. How to solve this problem?
I use Apache Maven 3.3.9, and use the command:
mvn clean deploy
--Addition: example of pom file I'm using:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<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>
<name>GitHub my_repo Apache Maven Packages</name>
<url>https://maven.pkg.github.com/my_nick/my_repo</url>
</repository>
</repositories>
<version>1.0.0</version>
<groupId>x</groupId>
<artifactId>some-plugin</artifactId>
<packaging>maven-plugin</packaging>
<dependencies>
<dependency>
<groupId>x</groupId>
<artifactId>my-dependency</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.15.12</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
</plugins>
</build>
</project>
Unfortunately I haven't found the right answer to my question, it seems that for now it's impossible to add Maven plugins to Github Packages.
However I found a workaround which uses S3 as a repository backend, so you don't need heavyweight solutions like Nexus or JFrog. You can read this and this on how to do it.
I had the same problem 422 from server: Unprocessable Entity when publishing Maven artifacts from GitHub Actions to GitHub Packages. The reason was that the corresponding tag for the uploaded artifact didn't exist yet.
The error message may be better in this case.
If you have already uploaded the artifact to the GitHub Packages then it means you have configured everything right.
I suppose the real reason for the 422 error is that you are trying to upload the same artifact with the same version that already was uploaded. And if it is not a SNAPSHOT version then the repository should deny replacing it so it behaves correctly.
I got the same error when trying to redeploy the already deployed package:
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project MavenPluginForGithub:
Failed to deploy artifacts: Could not transfer artifact ru.dmochalov:SampleMavenPluginForGithub:jar:1.0.3 from/to github (https://maven.pkg.github.com/dmochalov/hello-world):
Failed to transfer file: https://maven.pkg.github.com/dmochalov/hello-world/ru/dmochalov/SampleMavenPluginForGithub/1.0.3/SampleMavenPluginForGithub-1.0.3.jar.
Return code is: 422, ReasonPhrase: Unprocessable Entity. -> [Help 1]
How to fix?
Is suppose you have two options:
Increment the version <version>1.0.0</version> of the plugin from 1.0.0 to 1.0.1. Consider using 1.0.1-SNAPSHOT versions if the plugin is unstable and under development. GitHub allows redeploying artifacts with SNAPSHOT versions. So you could always redeploy it when developing.
Delete the package from the repo. You can do it only for packages in a private repository.
422 error vs 401 error
I suppose that there is not accepted specification or standardization for error codes and different repositories behave differently. For example, the Maven Central repository replies with 401 error when attempting to replace the already deployed version.
Why GitHub decided to use 422 is a mystery. There is an answer in the community forum but without proper explanation.
Here's the official github link for how to do exactly that. However, since this doesn't seem to be of much help, here's a link to a gradle forum question that should help you with this. Best of luck!

Why some jar file not build?

<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
This dependency not be downloaded. What am I doing?
This has already been covered on another question, but there's new information.
Oracle Maven Repository
Starting in 2016, Oracle started posting its drivers to a secure Oracle Maven repository, and they post the instructions for how to use the repository on their site. The process looks like this:
Register for the site, if needed.
Create a Maven Master password for encryption, if needed.
mvn -emp [YOUR MASTER PASSWORD]
Add the Oracle server to your Maven settings.xml (~/.m2/settings.xml).
<servers>
<server>
<id>maven.oracle.com </id>
<username>YOUR ORACLE USERNAME</username>
<password>YOUR ORACLE PASSWORD</password>
<configuration>
<basicAuthScope>
<host>ANY </host>
<port>ANY </port>
<realm>OAM 11g </realm>
</basicAuthScope>
<httpConfiguration>
<all>
<params>
<property>
<name>http.protocol.allow-circular-redirects </name>
<value>%b,true </value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
Encrypt the Oracle password using Maven:
mvn -ep [YOUR ORACLE PASSWORD]
Add repositories to your Maven POM or settings.xml:
<repositories>
<repository>
<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>
</repository>
</repositories>
<pluginRepositories>
<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>
After you do this, Maven will be able to resolve the dependencies.
Maven Central
As of September 2019, Oracle has started posting its jars to Maven Central. If you can use those versions, then you can just update your dependency:
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
Oracle drivers can't be installed using maven, as stated by the author of this blog post:
Due to Oracle license restrictions, the Oracle JDBC driver is not available in the public Maven repository. To use the Oracle JDBC driver with Maven, you have to download and install it into your Maven local repository manually.
You have to download the correct drivers manually and then you can take one of two possible paths, namely:
Install the driver in your local maven repository
Define your dependency indicating the path to the jar file
Here a some examples of both cases:
Local maven repository
Download and extract the driver jar in your file system,
Then execute the following command
mvn install:install-file -Dfile=path/to/your/ojdbc6.jar -DgroupId=com.oracle
-DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar
Finally adjust your dependency, please notice that I have used a different groupId
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
Indicating the location of the jar file
This is quite simple and straight to the point, just put the jar file in some folder and indicate the path in your dependency, you can even use any project path but you will have to be careful with possible legal issues about the driver license or distribution rules; so I recommend you using the first option.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>6</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc6.jar</systemPath>
</dependency>
As this process needs to be repeated in every development machine, is worth to mention that you should leave some form of documentation indicating the need of this driver and the necessary steps to install it.
Regards
Yes, Oracle JDBC drivers will be available on central maven. 19.3 version is currently available and other versions will follow soon. Refer to this blog for more details. Also, check out the Maven repo to browse the available jars.

Why does Maven want to download a module from a remote repository

Given the following modules in my pom.xml
<modules>
<module>core</module>
<module>middle-layer</module>
<module>top-layer</module>
<modules>
Where top-layer depends on middle-layer which depends on core.
When I run clean install it will build and install core and middle-layer successfully, but not top-layer. It tries to download middle-layer from a remote repository instead of using the freshly built one in the local repository.
I do have a custom remote repository specified in my pom.xml:
<repositories>
<repository>
<id>custom</id>
<url>http://someaddress/maven2/</url>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
</repositories>
Why does it want to grab middle-layer from the remote repository?
Currently, everything is in SNAPSHOT-mode.
Middle layer dependency:
<dependencies>
<dependency>
<groupId>mygroup</groupId>
<artifactId>core</artifactId>
<version>2.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Top layer dependency:
<dependencies>
<dependency>
<groupId>mygroup</groupId>
<artifactId>middle-layer</artifactId>
<version>2.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
They all inherent their versions from the parent (currently at 2.0.1-SNAPSHOT) and I'm calling install from the parent pom.
Maven frequently prints messages about downloading things that it is not, in fact, downloading. It is considering the possibility that there is a newer snapshot available remotely than the last one build locally. This is why uploading snapshots is often a really bad idea.
I found the answer.
It was a typical problem between keyboard and chair.
The middle-layer is actually historically a WAR, not a JAR, that is to say: it includes some classes I needed in my top-layer. (It's not really called middle-layer of course).
So top-layer searches for middle-layer.jar and can't find it (because it's a WAR).
So I have to refactor some stuff to get the things I need from middle-layer into a new library JAR and make both middle-layer and top-layer depend on that instead.
Sorry to waste your time. :)

Maven. Adding maven repository for activiti

The problem is that I'm trying to make somelike the helloworld with Activiti but I have an error here
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-spring</artifactId>
<version>5.1</version>
</dependency>
the error is the following: 'Description Resource Path Location Type
Missing artifact org.activiti:activiti-engine:jar:5.1 pom.xml /IllMakeThisTestApp line 29 Maven Dependency Problem
Trying to resolve it I've found the following recomendation here: "The download contains all the libraries that you need to work with Activiti. But for developers that prefer to use Maven, add the following reposiory"
<repositories>
<repository>
<id>Alfresco Maven Repository</id>
<url>https://maven.alfresco.com/nexus/content/groups/public/</url>
</repository>
</repositories>
But where shall I place it? To the file called settings.ini placed in M2_HOME/conf? This file is full of comments with no any sign of repositories. So I have no idea how to do this and ask you for help
You should place that in your pom.xml - see the Maven reference on the subject:
<project xmlns="http://maven.apache.org/POM/4.0.0"...
...
<repositories>
<repository>
<id>Alfresco Maven Repository</id>
...
You will only need to tinker with the Maven config if you need to setup a mirror for the repo, eg. in case your organisation has it's own Nexus/other repo mirroring the outside "world".
Cheers,
You can place right under project. For example
<project>
....
<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
In default maven will try to download all the artifacts from maven central. You can add any number of added repositories using tag given above. Alfresco is yet another open maven repository.

Categories

Resources