How can I update my Flink version programmatically - apache-flink

At the moment I have Flink 0.8.1 installed on my machine. I installed it via Maven and would like to know how I can update it. Do I have to deinstall everything in order to update to the current version? Or can I do it via Maven?

If you have a Maven project which depends on Apache Flink you can simply update the version of the Flink dependencies in your project's pom.xml file. Just run mvn clean compile again and Maven will fetch all required dependencies.
The old dependencies will remain in your local Maven repository (~/.m2/repository/). You can "uninstall" the old Flink dependencies by deleting the corresponding jar files.

Related

Feature repo add in KARAF Error Resolving Artifact : Could not read from local repo

Error executing command: Error resolving artifact
com.sample:features:xml:features:4.1.4-SNAPSHOT:
\[Could not find artifact com.sample:features:xml:features:4.1.4-SNAPSHOT in default
local (file:/C:{/Users}.m2/repository/),
Could not find artifact com.sample:features:xml:features:4.1.4-SNAPSHOT in apache
(https://repository.apache.org/content/groups/snapshots-group/),
Could not find artifact com.sample:features:xml:features:4.1.4-SNAPSHOT
in ops4j.sonatype.snapshots.deploy
(https://oss.sonatype.org/content/repositories/ops4j-snapshots/)\] :
com.sample:features:xml:features:4.1.4-SNAPSHOT.
I could not resolve this error after uncommenting local repository in org.ops4j.pax.url.mvn and add my local .m2 path
Thanks in advance for your suggestions.
You might have to reset your Apache karaf instance to fresh state.
Stop Karaf
Delete data folder from Karaf installation folder.
Start Karaf
Re-Install the features and bundles you need.
Alternatively you can try removing any features, feature-repositories and bundles that have been installed from there before removing the maven repository.
It's generally bad idea to remove/replace maven repositories from Apache Karaf from where user(s) might have already added new feature repositories, installed features and bundles.
Once tried to replace offline repository I had made with a new one which was missing some older artifacts. This lead to bunch of issues like inability to uninstall some of the older features.

How to build the project in Apache Flink core?

I'm beginner in Apache Flink and can't find any information about extending Flink core. I want start with simple: to build in one test-class. should I save that class as jar-file somewhere in flink?
I recently started developing small programs with Apache Flink, so I had the same problem. I advise you to use maven because it will allow to link all the dependencies you need and easily build your own classes.
You need to first install maven and then you can create a Flink Maven project with the following command:
mvn archetype:generate -DarchetypeGroupId=org.apache.flink -DarchetypeArtifactId=flink-quickstart-java -DarchetypeVersion=1.0.2
after that can add your classes to the src/main/java/[GroupId]../ and compile them with:
mvn package
Then, to run you newly created program you can execute the following command:
mvn exec:java -Dexec.mainClass="Package.YourClass" -Dexec.args="YOUR PROGRAM ARGUMENTS"
There are also tutorials all over the internet of how to run maven with an IDE if you want to.

why building flink-avro downloads SNAPSHOT flink jars

a question about building flink-avro.
i downloaded the source, and i am able to build complete source.
but when i move to folder
flink/flink-staging/flink-avro
and run command mvn package as i want to compile and run the tests, it starts downloading latest flink SNAPSHOT jars.
whereas, i have built the same jars from source, everything is there in local repo.
why it downloads the same things which are built locally?
You need to use mvn install on the top level module first. This will copy the built jars into your local maven repository located at ~/.m2/respository/. mvn package only builds the jars and put them in folder target (no copying into local maven repo happens).
After that, you can step into flink-avro and build there (either with mvn package or mvn install -- as long as no other module depends on the built jars, mvn package is fine). If you change something in a module A and another module B depend on A, you need to do mvn install in module A. Otherwise, module B cannot access the newly built jars from A.
Maven always looks for dependent jars in your local m2-repository first. If it does not find the jars there, it starts downloading them from the Internet. If it finds "old" jars in your local repo, it might still use them (depending on your specified maven update interval). On the other hand, even if you built mvn install locally, and a newer version is available online, maven might download the newer version.
Last but not least, sometime maven does not resolve the timestamp dependencies correctly or does not update the local repo even if you do a mvn install. Clearing the local maven repository (just do a rm for the corresponding jars or the whole repo) can resolve this problem.

appengine-maven-plugin versus maven-android-plugin

I'm trying to use Google Cloud Endpoints with Android client, built by Maven.
The problem is that appengine-maven-plugin v1.8.3+ require Maven v3.1.0+
[ERROR] Failed to execute goal com.google.appengine:appengine-maven- plugin:1.8.4:endpoints_get_discovery_doc (default) on project pro-gae: The plugin com.google.appengine:appengine-maven-plugin:1.8.4 requires Maven version 3.1.0 -> [Help 1]
while android-maven-plugin v3.6.1 doesn't (and will not) work with Maven v3.1.0 (see devs discussion at https://code.google.com/p/maven-android-plugin/issues/detail?id=395). The error
A required class was missing while executing com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.1:generate-sources: Lorg/sonatype/aether/RepositorySystem;
So I'm kinda locked out. One plugin asks for v3.1.0+, while the other one claims Maven 3.1.0 to be fatally buggy. So I left out to generate Endpoints client sources manually.
Any other ideas, besides waiting for fixed Maven 3.1.1? It doesn't seem to happen soon, because Maven 3.1.0 was released more than two months ago.
The latest version of the Android Maven Plugin is 3.8.0 and it now requires Maven 3.1.1+. This should allow you to use the latest appengine plugin as well. And Maven 3.1.1 has been released in the meantime as well.
Update Sept 2015: Latest version of the plugin is 4.3.0 with 4.3.1 around the corner. The 4x branch works with Maven 3.0.5+ but we strongly encourage users to use the latest Maven release.
Hmm, looks resolved by just using older version (1.8.2) of appengine-maven-plugin.
One other way of building is to configure the Run Configuration to use an external Maven Runtime.
To do this in Eclipse for Windows :
Right Click Project -> Run Configuration -> Create a new configuration -> In Main tab configure Maven Runtime.
I hope this helps.

Maven update with new file with the same version

I am using Maven and have a problem - if my colleague update jar file - Maven doesn't update it. So I have go to .m2/repository and manually delete it. After this Maven update dependance jar correct.
But may be exists another way to adjust, without each time delete manually?
Thanks.
First, you should make sure that your colleague's artifact is released with a SNAPSHOT version number as long as it it is not yet stable (see http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-pom-syntax.html#pom-relationships-sect-snapshot-versions). This will cause Maven to check for updates regularily.
To specify how often the check occurs, you can modify the updatePolicy of the repository to which your colleague deploys (see http://maven.apache.org/settings.html#Repositories). You can set it to always to make Maven pull snapshot updates as soon as your colleague deploys them.
You can also add -U to the mvn command to force maven to check the repository for updates (mvn clean install -U) but like dosendoc said first make sure you're working off SNAPSHOT versions.

Resources