OpenCV-2.4.4 POM entry Tag - maven

I am starting OpenCV in Java and want to get started by creating a maven project.
For that I am using OpenCV-2.4.4 jar.
But was not able to find out the pom entry needed for that jar to be included in the dependency.
Tell me if I am missing something too trivial. Or where to find the POM entry for the same.
All I was able to find was the pom entry for the google version:
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<classifier>linux-x86_64</classifier>
<version>0.3</version>
</dependency>
But I need the pom tag for OpenCV-2.4.4.jar

as far as I can see from the http://code.google.com/p/javacv/#Quick_Start_for_OpenCV_and_FFmpeg you should:
point your pom.xml file to the Maven repository
http://maven2.javacv.googlecode.com/git/, and make sure that the
library files of OpenCV and FFmpeg (*.so, *.dylib, or *.dll) can be
found either in their default installation directories or in the
system library PATH, which under Windows includes the current working
directory.
To add new maven repo, you can follow:
http://www.mkyong.com/maven/how-to-add-remote-repository-in-maven-pom-xml/
afterwards, it seems you can go for the latest version of javacv (present in repo):
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<version>0.5</version>
</dependency>
or maybe, as you specified (with platform specific classifier):
<dependency>
<groupId>com.googlecode.javacv</groupId>
<artifactId>javacv</artifactId>
<classifier>linux-x86_64</classifier>
<version>0.5</version>
</dependency>
UPDATE:
Sorry, I seem to miss the point with my previous answer. If you're trying to go with the OpenCV java bindings rather than JavaCV (http://code.google.com/p/javacv), there seems to be no maven packaging provided yet.
As the official tutorial uses ant only (http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html)
Moreover there is an open bug for what you expect: http://code.opencv.org/issues/3097
So the only option seem to be wait for resolution of the bug and use another way in the meanwhile.

I know OpenCV developers are working to make a public maven repository for Java bindings, but I've made an example that shows how to do it, pretty much like Java OpenGL deals with it.
The full example can be retrieved from:
https://github.com/JavaOpenCVBook/code/tree/master/chapter1/maven-sample
Remember to add the github repository, as pointed by:
<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/maven-v4_0_0.xsd">
<repositories>
<repository>
<id>javaopencvbook</id>
<url>https://raw.github.com/JavaOpenCVBook/code/maven2/</url>
</repository> </repositories>
<modelVersion>4.0.0</modelVersion> … </project>
For now, there are only windows 64 and 32 native jars available, but it should be easy to add your Linux/MacOS version of it.
Best regards,
Daniel

Related

versions-maven-plugin:update-property not updating pom.xml

Hi Meier I have used the following goal:
mvn versions:update-property
-Dproperty="emom.web.dependency.shr.version"
-Dincludes:org.safeway.com:emom-shr
-DgenerateBackupPoms=false
-DallowIncrementalVersios=true
-DallowSnapshots=true
clean package
My Job B pom.xml is:
<dependency>
<groupId>com.safeway.app</groupId>
<artifactId>emom-shr</artifactId>
<version>${emom.web.dependency.shr.version}</version>
</dependency>
Under the properties it has the version hard-coded:
<emom.web.dependency.shr.version>19.6.5-SNAPSHOT</emom.web.dependency.shr.version>
My Job A pom.xml:
<groupId>com.safeway.app</groupId>
<artifactId>emom-shr</artifactId>
<version>20.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
When I run the above goal, Maven is picking the latest version (i.e. 20.1.0) from Artifactory but when I check the pom.xml of Job B under properties it still says 19.6.5. I need a way to change the 19.6.5 or current version to latest version available. Am I doing something wrong? I'm not able to figure it out.
Here's an example of versions-maven-plugin:update-property working in practice. I've used the common Mockito library as an example that works for everyone as it's in Maven Central.
Starting with this POM (noting the mockito-version property):
<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>
<groupId>abc</groupId>
<artifactId>def</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<mockito-version>2.22.0</mockito-version>
</properties>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The simplest way to upgrade it to the latest release version is this:
mvn versions:update-property -Dproperty=mockito-version
Replace mockito-version with emom.web.dependency.shr.version in your case.
You can then start to use more of the goal options to adjust the options. For example, you might:
Permit snapshots, not just releases, with -DallowSnapshots=true.
Disallow major version updates (i.e. third element from the right) with -DallowMajorUpdates=false. Note that the logic around these version number sections seems a bit flaky in the plugin - or isn't how I expect.
Avoid creating backup POMs with -DgenerateBackupPoms=false. This is cleaner, but if you omit this option then you can use mvn versions:revert to get yourself back to where you started.
To apply this to your scenario, I think you need to:
Check you've not got typos in your actual command (like you have in the question and comments).
Get rid of options that don't appear in the options.
Probably, keep things simple by not trying to run this in conjunction with anything else (unless it's in automation), so get rid of the clean package at the end of the command.

How to import all provided Wildfly libraries in my maven project?

Is there a way to translate this human language in an xml codeblock that Maven will happily understand?
Hey Maven, look you are a great dependency management system. I am working on a JavaEE project which is intended to be deployed on Wildfly 10.1.0. Please put all Libraries that are specified in Wildflys parent BOM http://repo1.maven.org/maven2/org/wildfly/wildfly-parent/10.1.0.Final/wildfly-parent-10.1.0.Final.pom on the compiletime classpath and consider them as provided by Wildfly at runtime. And please dont bother me to list every single referenced artifact in the dependencies section of the projects pom file. Thank you Maven, you are so cool.
To clarify:
As far as I understand, importing the bom file in the dependencyManagement section of my pom file will only spare me to specify the Version Number of every single artifact, but I will still have to declare every artifactID and groupID.
This is indeed discussed here How to use BOM file with Maven
But in this answer is also stated:
Then you do not have to specify the version attribute of a dependency.
I would prefer to declare only that I am using wildfly and then be able to use all client libraries without declaring any other dependencies.
But I must admit, I have the feeling to miss something obvious. There should be an easy way to do this.
If you want everything in a another pom to be set as a dependency and as provided you can specify that in your pom. A minimal pom for wildfly 10.1.0.Final that includes everything seems to be as follows:
<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>
<groupId>wft</groupId>
<artifactId>wft</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>wft</name>
<description>wft</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-spec-api</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
But I would still recommend doing it the way that wildfly does it themselves, which is to put the BOM in the depencency management section and declare artifacts as you need them. Why? I don't know other than it's cleaner to read and maybe easier for maven/java to compile and build.

Intellij - Add project as dependency to another project

I am trying to make my project work on intellij (it works with eclipse). I have a project with this in my pom:
<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>
<groupId>com.fitnetapplication</groupId>
<artifactId>fitnet-common</artifactId>
<version>6.0.2-Final</version>
<packaging>war</packaging>
<name>FitnetCommon</name>
<description>Socle Commun FitnetManager / SyrhaLogic</description>
Now i have another project which needs to be linked to this one, so I had:
com.fitnetapplication
fitnet-common
6.0.2-Final
runtime
war
<dependency>
<groupId>com.fitnetapplication</groupId>
<artifactId>fitnet-common</artifactId>
<version>6.0.2-Final</version>
<type>jar</type>
<scope>provided</scope>
<classifier>classes</classifier>
</dependency>
The problem is that on Intellij, the version is not accepted for some reason, I don't know why, it tells me that the version 6.0.2-Final is not found for the artifact fitnet-common
To confirm - you are actually running mvn clean install (or similar) on the first project before trying to resolve the dependency in the second project?
If you are, it sounds like you're installing the project using one Maven repo location, and then in the other project it is looking in a completely different location. Are your .m2 location settings identical for both projects?
Edit:
Is it because you're specifying the first project as a war packaging, but in the dependency declaration you are looking for a jar? They would essentially be two different artefacts:
.war - com.fitnetapplication:fitnet-common:6.0.2-Final:war
.jar - com.fitnetapplication:fitnet-common:6.0.2-Final:jar
Check in your .m2/com/fitnetapplication/fitnet-common/6.0.2-Final to see what you have there, likely it is just the war file.

Is there a working maven pom for vaadin FancyLayouts addon?

I have decided to use a layout addon in my Vaadin project which is a maven project, but after taking the maven pom available on the addon page, it somehow fails to resolve from the maven repository.
Please can some tell me how to get a working maven pom or how I can get around this?
Here is the maven
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<dependency>
<groupId>org.vaadin.alump.fancylayouts</groupId>
<artifactId>fancylayouts-addon</artifactId>
<version>0.2.1</version>
</dependency>
To make this addon work into your maven project layout, you need to download the project zip bundle from github.
Extract the zip content to any directory and cd into the addon folder:
unzip FancyLayouts-master.zip
cd FancyLayouts-master/fancylayouts-addon/
Once there, using your favorite text editor, change the first lines of the pom.xml. Replace the <parent>...</parent> tags along with its content with the version tag (althoug the addon page in the vaadin directory says that the addon version is 0.2.1 the project code version for the downloaded bundle is 0.3-SNAPSHOT). The first 14 lines of the file should look like this:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.vaadin.alump.fancylayouts</groupId>
<artifactId>fancylayouts-addon</artifactId>
<packaging>jar</packaging>
<name>FancyLayouts addon</name>
<description>FancyLayouts Vaadin addon</description>
<version>0.3-SNAPSHOT</version>
<organization>
<name>Sami Viitanen</name>
<url>http://vaadin.com/alump</url>
</organization>
Build the addon using: mvn install
It should build successfully and install automatically into your local repository, to reference it from your project, add the following dependency:
<dependency>
<groupId>org.vaadin.alump.fancylayouts</groupId>
<artifactId>fancylayouts-addon</artifactId>
<version>0.3-SNAPSHOT</version>
</dependency>
Explanation of the workaround: If you try to install the addon using just mvn install and then reference the dependency in your pom.xml, maven will complain about not finding the parent pom for this library (something like: Cannot find parent: org.vaadin.alump:fancylayouts for project), thats why we have to delete the parent tag and rebuild the addon without it

Maven can't find httpcomponents-client in repository

I am trying to add the Apache httpcomponents-client library to my Maven project. I have added a dependency to pom.xml (as found on http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcomponents-client/4.1.1), but when building my Eclipse project Maven is unable to find and download the library.
I have made a test project which does nothing but include this library to ensure that it's not any other settings that cause problems:
<?xml version="1.0"?>
<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>
<groupId>no.gundelsby.test</groupId>
<artifactId>NeedMyPackage</artifactId>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcomponents-client</artifactId>
<version>4.1.1</version>
</dependency>
</dependencies>
</project>
Building this project results in the same error.
Other things I have tested:
Tried building with vanilla installs of both Maven 2.2.1 and 3.0.3
Had a friend build the test project on his computer to rule out local problems on my computer
Changed the version from 4.1.1 to 4.1
For what it's worth I had the same problem a few days ago with org.easytesting.fest-swing, see pom dependency entry below:
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-swing</artifactId>
<version>1.2.1</version>
</dependency>
You don't want httpcomponents-client as a dependency. That's just the parent pom for the client-related modules. I suspect you actually want <artifactId>httpclient</artifactId>.
Here a simple solution...
Its great for me...
You can downloar jar file from internet and add manually to project from netbeans or another IDE.
Here an example for you:
enter image description here
Search the downloaded jar in your computer
enter image description here

Resources