gwt with maven and bootstrap eclipse starter project - eclipse

I struggle for a few days now with integrating maven and gwt in eclipse. I was searching web for some ready to import project, but unfortunatelly everything crashed so long.
I am new to gwt. I would like learn it. Earlier I was using maven, spring and playframework with sbt.
I haven't use ant like build tool. But I like it integration between gwt and eclipe (I can click run in super dev mode).
One think is that I do not like in ant, I have to manually download jar and put it in classpath. I think it is unnecessary if maven can do it for me.
I would like also to use this library: gwtbootstrap3
I can't handle this on my own.
Can someone of You prepare for me that eclipse project, that I could just import.
Here is my newest pom.xml:
<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>pl.korbeldaniel.btsp</groupId>
<artifactId>btsp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>btsp</name>
<properties>
<gwt.version>2.7.0</gwt.version>
<gwtBootstrap3.version>0.9.1-SNAPSHOT</gwtBootstrap3.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
<build>
<finalName>btsp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
But I cant run in like native gwt project.

Yes, it's a definitely possible. You just have to sift through a ton of documentation to figure it out.
You'll need Google Plugin for eclipse and the m2e (Maven Integration for Eclipse) plugin
After you have those, right click on a GWT project-> configure -> convert to Maven Project.
Now, to use GwtBootstrap3, all you need to do is add GWT and gwtBootstrap3 as dependencies in your pom. (Details here).
If you need any ready to import maven projects, you can clone GwtBootstrap3-demo project from github and run that as a web application. As for learning GWT, tutorials are your best option (Pay close attention to UiBinder for GwtBootstrap3).
click here, here and here for details about setting everything up.

Related

How to handle Dependencies in Eclipse Plugin Project using Tycho

I'm writing an eclipse plugin and I'd like to manage it using Maven, specifically dependencies.
Here is my pom.xml file:
<?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>com.example.plugin</groupId>
<artifactId>SomePlugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<tycho.version>0.24.0</tycho.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-versions-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>luna</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/luna</url>
</repository>
</repositories>
</project>
I can successfully build this project, however Junit is not visible in my project, I'm not able to call any classes or method from Junit. So it seems I'm not properly using dependencies . Any idea how I can use dependencies? Junit is just an example, no dependency is available to me after a successful build.
I'm a noob to plugins and Maven so any help or guidance would be much appreciated.
You can create a p2 repository from a location of your own filled with jars/plugins/features (also put there jUnit) and then just add that repository to your pom.xml; the external dependency is not a good idea I think, I would recommend using a cached local repository.
How to create p2 repository : http://wiki.eclipse.org/Equinox/p2/Publisher#Features_And_Bundles_Publisher_Application.
Also, when building your Eclipse RCP product, use a custom target platform and also dump in there Eclispe SDK, JUnit+others jars, etc (just google Eclipe target platform)
A very late answer. For those who come on this now, there is the Orbit Eclipse repository which contain a lot of libraries useable with Tycho builds. Junit is one of these.

FailOnMissingWebXml error when validating pom.xml in Eclipse

When compiling a Maven project I get this error during validation phase of the pom.xml. It is quite a large project with complex build process. The project contains only JavaScript code and does not have to be compiled into war. I'm looking for a way to either:
Just disable the error through disabling failOnMissingWebXml (it appears to be a non-critical Eclipse error)
Find a solution that prevents this validation error in Eclipse (answers to related
questions didn't work for my specific scenario)
The full error:
Description Resource Path Location Type web.xml is missing
and <failOnMissingWebXml> is set to true pom.xml /testproject line 6
Maven Java EE Configuration Problem
After clicking on the error the problem seems to be on this line of pom.xml:
<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.scs</groupId>
<artifactId>scs-control-panel</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging> **THE ERROR POINTS TO THIS LINE**
<parent>
<groupId>com.scs</groupId>
<artifactId>scs</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../scs</relativePath>
</parent>
<build>
</build>
<dependencies>
</dependencies>
</project>
Not sure if this is an Eclipse or Maven error, but probably Eclipse, since Maven runs smoothly through command line. It may also be a bug in Eclipse, I'm running Eclipse Java EE IDE for Web Developers Version: Mars.1 Release (4.5.1).
UPDATE1: I tried updating the project in Eclipse but no difference.
UPDATE2: I tried changing the package type from war to pom but no difference.
Everything in Maven revolves around plugins. Plugins are the programs that execute some behavior within the build process. Some plugin inclusions are implied without us having to declare anything.
These implied plugins have default configurations. For example, the maven-compiler-plugin is included in all projects without having to declare it. To override the default configurations we need to declare the plugin in our pom.xml file and set the configurations. For instance, you will see a lot of projects override the default version on the maven-compiler-plugin which has it's source and target set to Java 1.5. We can change to 1.8
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
This is just some theory behind the plugins to give you an idea of what's going on.
With that being said, in order to use <packaging>war<packaging>, the maven-war-plugin is used without us having to declare anything. Just like when using <packaging>jar</packaging>, the maven-jar-plugin's inclusion is implied.
The default configuration for the maven-war-plugin is to fail where there is no web.xml (that configuration property being failOnMissingWebXml). So if we want to override this default, we need to declare the plugin, then set the value for the property to false (not fail)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
UPDATE
The war plugin now allows you to just use a property that it will lookup. This allows you to simply declare the property without having to override the plugin. To add this property, you would simply add the property failOnMissingWebXml with a value of false to the project <properties>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
Just by adding this, if you have no further configurations you need to add to the compiler plugin, you will no longer have to override and declare the compiler plugin in your pom.
UPDATE 2
So if you declare the maven-war-plugin and use a <version> 3.0.0+, the default for no web.xml failure will be set to false, so we no longer have to override the configuration property, though we still need to declare the plugin.
Do:
mvn clean eclipse:clean
Add this to your POM:
<packaging>war</packaging>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
I guess the easiest path is to choose the war plugin version 3. The default value for failOnMissingWebXml has been changed from true to false.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
Once set in your pom the nasty error vanishes for ever.
Add the below property to POM.xml
<failOnMissingWebXml>false</failOnMissingWebXml>
I was able to resolve this problem by adding this property in POM.xml as like below.
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

Running Scala code in Eclipse with Maven enabled

I am trying to run some trivial Scala code in Eclipse but I am not able to get it working when Maven is enabled.
I start by creating a Scala project in Eclipse and then I add an object with the following code:
object HelloSpark extends App
{
println("Hello, world!")
}
I then use "Run As>>Scala Application" to successfully execute the above code:
Hello, world!
I then enable Maven by clicking on "Configure>>Convert to Maven Project". While the ensuing build is successful, the "Run As>>Scala Application" option no longer comes up. Using the previously created launch configuration results in the following error:
Error: Could not find or load main class HelloSpark
Trying the answer for Eclipse, Scala & Maven - Class files are not generating did not help in my case.
Could someone please tell me what I am doing wrong? I don't understand why enabling Maven changes the way Scala code is run.
Thanks.
Edit: Here is the pom.xml that was automatically generated when I converted the above to a Maven project:
<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>HelloSpark</groupId>
<artifactId>HelloSpark</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
Usually when you have a maven project, the project is build with maven. Therefore you need a pom.xml file where you define how to build the project and so on. Are you aware of this, did you configure a pom.xml? Without the correct pom file you cannot build and run the app.
So without a correct maven build, you will not have a class file. Therefore you are getting this error: Error: Could not find or load main class HelloSpark
So it turns out simply converting the Eclipse project to a Maven project is not enough. Maven has to know it's a Scala project and build it accordingly.
I followed the instructions at http://docs.scala-lang.org/tutorials/scala-with-maven.html and now I have a working project with running code. It's important to generate a Maven archetype first and then convert it to an Eclipse project before importing it into Eclipse.

Missing artifact log4j:log4j:bundle:1.2.17

I created a dynamic web application in eclipse Version: Kepler Service Release 1 using menu.
After that I converted it into a maven project using
configure -> convert to maven project. Then I did
maven->Add dependency and then searched for log4j.
After adding that on hovering over the tag
for log4j it displays Missing artifact log4j:log4j:bundle:1.2.17.
I can't update dependencies using maven. How to fix it?
Please also explain the reason for the error.
Here is the generated xml after adding log4j.
<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>Healthcare</groupId>
<artifactId>Healthcare</artifactId>
<version>0.0.1-HEALTHCARE</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>bundle</type>
</dependency>
</dependencies>
</project>
First why did you changed the default source folder location? The default is src/main/java and for webapp src/main/webapp. Apart from that a bundle for log4j does not exist on Maven Central just remove the <type>bundle</type> from your dependency, cause in Maven Central only a jar is available.
I always do the following trick:
In the dependencies management i edit the dependencies properties (select the dependencies with problem and click on properties button) changing the type from bundled to jar and that fixs the problem.
Well i hope that this solution work for you :) regards,
I too played with all the options provided above but it did not helped. By updating Maven dependencies forcefully my issue got resolved.
Go to project >> Maven >> Update Project
select the project and click OK.
Project will automatically try to download required jar but if still you are getting same error then do below step.
Go to project >> Maven >> Update Project >> check in the checkbox 'Force Update of Snapshots/Releases'
select the project and click OK.
Please check if the dependencies are correct or if it is missing.
<properties>
<springframework.version>4.2.1.RELEASE</springframework.version>
<jackson.version>2.5.3</jackson.version>
<log4j.version>1.2.17</log4j.version>
</properties>
By default (and the common usage), Maven would consume jars as a dependency. Just change the bundle to jar in your pom.xml file in the given dependency which is giving you an error.

Eclipse - how to make a Maven + OSGI project?

I am new to OSGI and Maven and trying to figure out how to make a maven-osgi project in Eclipse. I have followed the tutorials and im able to make a maven project and also an OSGI project but I cant make a project that holds both of them.
As I understand the most important part of the OSGI project is manifest.mf. In my OSGI project I have this:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Osgi
Bundle-SymbolicName: osgi
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: osgi.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
And the most importand part of an maven project is its pom.xml. In my maven project i have 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.videobet.test</groupId>
<artifactId>quick</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>quick</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Now to combine these two I tried to make a maven project first and then edit the pom.xml so it would add the dependencies of an OSGI project and make the manifest.mf. For that I tried to add something like this:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
But I was unsuccessful. First of all I got an error like this:
Plugin execution not covered by lifecycle configuration: org.apache.felix:maven-bundle-plugin:2.4.0:manifest (execution: bundle-manifest, phase: process-classes)
and even if i could resolve that im not sure if that would work. I also found different plugins like tycho that should help with the task but i dont really want to use them. I want to keep things as standard as possible and do things myself so i would eventually understand what im doing :)
Any help would be appreciated!
There is a other way to create Bundles with Maven have a look on Maven Tycho.
If you want work and deploy with Eclipse Environment then you can also use this Tutorial:
http://www.vogella.com/tutorials/EclipseTycho/article.html
This is the Manifest first approach.
With Maven Tycho you can create your own P2 Repository (and also a ZIP file) for your different Applications to Import in other Eclipse RCP Environments.
There is a video that helps getting started to make an application with Eclipse+Maven+OSGi at https://www.youtube.com/watch?v=JNH6JVmAcIQ&t=432s
The video starts with a fresh Eclipse and an empty maven project, so if you do the same steps, it should work for you.
Also, there is cookbook at http://cookbook.everit.org/
The goal of the cookbook to help people getting started with OSGi based on Maven (and optionally on Eclipse).
The cookbook has not been updated for a while as it was waiting for the eclipse plugin. As the Eclipse plugin works now, the cookbook will be rewritten soon.