Is there a working maven pom for vaadin FancyLayouts addon? - maven

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

Related

Install remote maven artifact to local repository

I would like to install an artifact from maven central repository to my local repository. Can anyone help me on getting this? With other words, I want some jars from maven central repositories to be downloaded into my local repository, but using maven, not going in browser and downloading needed jar files.
I am not entirely sure why would you want artifacts from maven for reasons other than using them in a maven based project... But since that's what you want:
Maven installs artifacts locally when they are used - that is when you install a project that has them in dependencies. Therefore the simplest solution would be to create a dummy project, put the artifacts you want as dependencies and install it. Something like:
<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>dummy</groupId>
<artifactId>dummy</artifactId>
<version>dummy</version>
<dependencies>
<-- artifacts you want -->
</dependencies>
</project>
within pom.xml file in an empty folder. It will additionally create a dummy artifact in your local repository you might want to get rid of manually if it bothers you.

OpenCV-2.4.4 POM entry Tag

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

Adding A Group of Files to a Local Maven Repository

I have an existing java project. It is a maven project. I want to add it to my local maven repository for reuse in other projects.
MyUtilityClass.jar
MyUtilityClassSources.jar
MyUtilityClassDocs.jar
Dependent on
slf4j-1.7.2.jar
junit-4.11.jar
This SO Question/Answer gives instructions for adding a single file to a local maven repository using mvn install:install-file
This SO Question/Answer gives instructions for adding a group of jars - sources, javadoc, etc. using mvn deploy-file.
This SO Question/Answer alludes to specifying dependencies via a pom.xml file, but doesn't provide details.
I have two tasks in front of me that I'd like to accomplish:
add the project for MyUtilityClass to my local repository, with sources, docs, and dependencies automatically added when I pull them in.
I'd like to create a maven task for the MyUtilityClass project that adds the latest and greatest bundle to my local repository.
I am using eclipse as an IDE and maven version 3.0.4. The POM for this project looks 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.local.mine</groupId>
<artifactId>MyUtilityClass</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyUtilityClass</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>com.local.mine</groupId>
<artifactId>slf4j</artifactId><!--from local repo -->
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>com.local.mine</groupId>
<!--from local repo and shouldn't be automatically added -->
<!-- to projects that reuse the resulting bundle -->
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</project>
The easiest way to do this is to think of each project as their own release cycles. They should be independant of each other.
As you have discovered, you can
use install to install the artifact to your local repository
use install-file to install secondary artifacts to your local repository
use deploy to so the same steps as install(-file), but to remote repositories
What also does this is the release plugin. When you perform the pair goals of release:prepare and release:perform, you end up with
version values update in the pom files
version control tags created
the artifact installed & deployed
any source and/or javadoc artifacts deployed
What you want to use is the release plugin.
The simple solution is to use
mvn install
in the project you would like to reuse. This will install the artifacts of your project into your location repository.

Why Maven is looking for .pom file when .jar is present in the repository?

I have the following dependency in my pom.xml
<dependency>
<groupId>aGroup</groupId>
<artifactId>anArtifact</artifactId>
<version>aVersion</version>
</dependency>
I also have the anArtifact-aVersion.jar file in ~/.m2/repository/aGroup/anArtifact/aVersion directory.
When I start building the project, maven looks for a .pom file instead of using the .jar file and attempts to download the following
http://repo1.maven.org/maven2/aGroup/anArtifact/aVersion/anArtifact-aVersion.pom
How can I configure maven to use the existing .jar file?
Every jar needs to have a pom file describing it, you can just add something simple like this:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>aGroup</groupId>
<artifactId>aArtifactId</artifactId>
<version>aVersion</version>
<packaging>jar</packaging>
<name>a Name</name>
</project>
Run your build using the "-o" switch to use Maven in offline mode. In offline mode, Maven will not check for updates of snapshot dependencies in remote repositories.
the best way to install an artifact to the local repository which were not built by Maven ist to use
mvn install:install-file ...
have a look at the install:install goal.
POM that is installed to nexus will describe the jar. Used to pull the dependencies that are associated to corresponding jar. When we add the jar as dependency to our project, all the jars required for the included jar will be identified through the corresponding pom.
It is looking for the pom to, among other things, resolve the transitive dependencies.

Maven Systempath not working as expected

I have specified following dependencies(For example mentioned one here) in pom.xml which will look for saaj.jar under the specified sytempath and Maven used to pick it from same path and working fine.
<dependency>
<groupId>saaj</groupId>
<artifactId>saaj</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/saaj.jar</systemPath>
</dependency>
Now I have moved to windows 7 and Spring Tool suite 2.7.1 version(Previously Win XP and Spring older vesion). In this new setup am getting below error.
Missing artifact saaj:saaj:jar:1.0:system
Now, It is looking for saaj-1.0.jar instead of saaj.jar and under the folder ${basedir}/src/main/webapp/WEB-INF/lib/saaj/saaj/1.0/ instead of ${basedir}/src/main/webapp/WEB-INF/lib/.
Why is it so? Please provide the solution where my previous setup should work fine.
Avoid systemPath, you must create a local repository like :
this is you pom file :
<repositories>
<repository>
<id>local-repo</id>
<url>file://${basedir}/lib</url>
</repository>
</repositories>
<dependency>
<groupId>tiago.medici</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1</version>
</dependency>
on project you create a lib folder to put your jar and maven pom file generated from
mvn install:install-file -Dfile=c:\tiago.medici-0.0.1.jar -DgroupId=tiago.medici -DartifactId=eureka -Dversion=0.0.1 -Dpackaging=jar
tiago.medici-0.0.1.pom
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>tiago.medici</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1</version>
<description>POM was created from install:install-file</description>
</project>
Don't use system scope. It was meant for system provided libraries. Given the path you gave for it, you are obviously creating a web application.
Use a war project and specify your dependencies with provided scope if they're already available (e.g. because they are provided by your application server) or without a scope specification otherwise. Maven will take care of packaging your project dependency in a correct way, both for Eclipse development and for deployment in your application server.

Resources