I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

Wednesday, 10 July 2013

Maven Apt and Code Snippets

For a documentation and course I will give I am using the document creation properties from apt of maven. For a documentation of the format see:
the APT format. In order to give an example, you can use a very simple snippet:

    ------
    The APT format ( or the html title of the document)
    ------
    Me the author
    ------
    2013-7-9


The title at the top of the page (not indented)

  The first introduction paragraph.... which is indented so that it is clear that it is a paragraph.

* The first subsection

  Another paragraph also indented

** a subsection with two * in order to mark it as a sub subsection

  A third paragraph followed by an ordered list with numbers

    [[1]] first element

    [[1]] second element


This create the following snippet HTML fragment (in a given generated page).



<h2>The title at the top of the page (not indented)
<a name="The_title_at_the_top_of_the_page_not_indented"></a></h2>

<p>The first introduction paragraph.... which is indented so that it is clear that it is a paragraph.</p>

<div class="section"><h3>The first subsection

<a name="The_first_subsection"></a>

</h3><p>Another paragraph</p>

<div class="section"><h4>a subsection with two * in order to mark it as a sub subsection<a name="a_subsection_with_two__in_order_to_mark_it_as_a_sub_subsection"></a></h4>

<p>A third paragraph followed by an ordered list with numbers</p>

<ol style="list-style-type: decimal"><li>first element</li><li>second element</li></ol></div></div></div>

In order to get snippets, then I use snippet macros as described in: Guide to the Snippet Macro.

Thursday, 2 September 2010

Maven Repository in PHP or Virutal machine for Maven Repository

Since I would like to put my software in a maven repository, and since it is difficult to find Java/JSP enabled providers in Europe. I was wondering whether I should not try to reimplement the archiva project directory with PHP or perhaps Ruby.

After having a look, it does seem quite a lot of dirty work. But it is probably not too complex to perform. But is it worth it ?

Thursday, 22 April 2010

Flex - generating Flex on Java Project

I collected the following from The Flex On Java Book.

$workspace > mvn archetype:create -DarchetypeGroupId=org.foj -DarchetypeArtifactId=flex-mojos-archetype -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=org.foj -DartifactId=flex-bugs-ria -DremoteRepositories=http://flexonjava.googlecode.com/svn/repository

However, I still need to solve some dependency problems. In particular I needed to install the following packages:

  • com.adobe.flex.compiler:asdoc:zip:template:3.2.0.3958
  • org.graniteds:granite-generator:jar:1.1.0
  • com.adobe.flex:compiler:pom:4.0.0.7219

But this is solved by using the correct repository by adding
<repositories>
   ...
    <repository>
       <id>flexcompiler-repo</id>
       <url>http://repository.sonatype.org/content/groups/flexgroup/</url>
    </repository>
</repositories>

However, after running:

$flex-bugs-ria >mvn package
it runs quite a while with an error. It seems it just could not start the flash player. So it may be all good ;-).

It returns successful and the generated swf can be displayed in the browser

$flex-bugs-ria >mvn package-Dmaven.test.skip=true

Next step: do a more complex flex example.

Wednesday, 21 April 2010

Installing qwt (Qooxdoo Windowing Toolkit)

After trying qooxdoo, I natually tried QWT, which is a simple implementation of the windowing toolkit with java. The default project generated for qwt is basicall the same as the one provided by qooxdoo. However, the main idea is to use java as programming language. The javascript components are then generated I suppose.

Getting QWT to run with maven without the installed Maven

The QWT install package contains a maven instance. However, I already have two instances of maven installed on my computer, therefore I prefered using my own maven instance. This worked quite well after I installed the qooxdoo files as well as some eclipse base package in my local repository. Moreover I need the following setting:

<settings>
  <pluginGroups>
   <pluginGroup>org.qooxdoo.toolkit</pluginGroup>
  </pluginGroups>
</settings>

Then I could use the qwt project generator: $qwt-workplace> mvn-jul qx:new -Dpackage=de.deprofundis.exampleqwt -Dorg.apache.maven.global-settings=`pwd`/../qwt-0.2.0/bin/settings.xml
and then I could change in the directory "exampleqwt", where there is a src directory as well as a pom.xml.

Installing the project in my repository was easy:
$exampleqwt> mvn package -Dorg.apache.maven.global-settings=`pwd`/../qwt-0.2.0/bin/settings.xml
Then using qx:run task from the qwt maven plugin:
$exampleqwt> mvn qx:run -Dorg.apache.maven.global-settings=`pwd`/../qwt-0.2.0/bin/settings.xml

This started an instance of tomcat on port 8080. Therefore I could then test the application.

First Comments

The generated code is an index.html (or index.html.gz for browser/servers supporting gz I suppose. This is a huge html file containing the core content of the javascript for running qwt. I wonder why the programmers have not put this generated code in a javascript file and loaded this file.

The directory layout of a qwt project is described in a wiki page: directory_layout. Note that, there is a logging mechanism. Though I have not yet looked at what it really does. There is also a list of the modules to be loaded and the index.html which has been created.

From all this, it is not yet clear to me how to have a more modular approach, so that the qooxdoo code does not need to be loaded every time I need a qooxdoo component. I suppose this might be solved in a later version of the code.

Caveats

According to the following page of the documentation, QWT only works in a Tomcat 6 Servlet instance:

In order to distribute your QWT application, simply run mvn clean package to generate a target/yourapp-version.war file. Your application should run in any Tomcat 6 servlet container. QWT applications follow Sun’s servlet specification 2.5. Unfortunately, the servlet specification has currently no support for “reverse Ajax” (sometimes called “Comet”). QWT uses Tomcat 6 features to work-around this limitation. As a consequence, you cannot deploy in other servlet containers.

Thursday, 14 January 2010

ROO - a spring and Maven based rapid development framework

I just discovered ROO. I tried it. But I had some problems running it under fedora with java 1.6 and maven 2.0.8. It seems that it need maven 2.0.9. The idea behind roo is to have a command line based system to develop. It is somewhat similar to Ruby on Rails. You issue commands and create and edit the entities that way. I give here an example of script:
project --topLevelPackage org.myexample persistence setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT database properties list database properties set --key database.url --value jdbc:hsqldb:${user.home}/tmp/datasources/my-example database properties list
This first part of the script creates a project pom.xml (for maven) and sets the necessary properties for working with hibernate using an in memory database.
entity --class ~.domain.MyExample field string code --notNull --sizeMin 32 --sizeMax 32 field string firstName --sizeMax 65 field string lastName --sizeMax 65 field string email --sizeMax 65 field number age --type java.lang.Integer field date confirmed --type java.util.Date
This second party from the script creates an entity: MyExample. It also creates a number of fields: code, firstName, lastName, email. The next part of the script takes care of creating controllers and tests. The line:
controller scaffold ~.web.MyExampleController
creates a controller for CRUD operations. It also performs the tests to make sure it works correctly. Finally, it sets up the logging framework as well as the security framework.
test integration controller scaffold ~.web.MyExampleController selenium test --controller ~.web.MyExampleController perform test // (OPTION: quit, mvn tomcat:run, localhost:8080/myexample, mvn selenium:selenese) logging setup --level DEBUG --package WEB security setup
The next section creates a new controller class called: org.myexample.web.My2ndExampleController. It lists the finders and adds the finder to the class.
controller class --class ~.web.My2ndExampleController finder list --class ~.domain.MyExample --filter code,equ finder add --finderName findMyExamplesByCodeEquals perform eclipse
At the end the perform eclipse sets the system for using the system under eclipse.

Thursday, 7 January 2010

The long way to a maveniozed Eclipse: M2Eclipse

I had some trouble installing everything for M2Eclipse. One part of the problem was that the fedora installation from eclipse did not really allow the installation of the correct packages. I used the description found in the free online book documenting M2: Developing with Eclipse and Maven.

Therefore, I downloaded the new eclipse from the web site and then I could install subclipse, AJDT and WST as needed. Though WST should have been there since it was the JEE version of eclipse.

Then I could install M2 from the http://m2eclipse.sonatype.org/update/ site.

It is interesting to have the poms. But since the poms are a little complex, I generate them from a more simple xml file. And these XML files can be generated using an even more simple XML file (though this is not yet finished). The goal is to help the bootstrapping of projects. In a simple manner.

Saturday, 19 September 2009

Quote the Maven: Evermore!

Well sorry about that my dear Poe! I really like Maven a lot. It is a really good programming management tool. It is a step up from Ant, yet it simplifies a lot of aspects. And moreover it has a very useful set of plugins and software repositories. The main properties of Maven:
  • Workflow and tasks based
  • modular
  • dependency management
  • extensible
  • platform adaptable

Workflow and tasks based

Maven is based on a controlled workflow of tasks performed, sequentially. You can call some particular task. Maven will make sure the tasks required before this task will be performed if needed. For example, if you wish to package a certain jar. Maven will take care of the compilation and the signing.

Modular

Maven is capable of working with different modules. The modules required by a given module will be then built if needed.

dependency management

At the heart of maven, there is a dependency management framework: Ivy. This allows to ensure that the packages used and constructed have a compatible version with the code needed.

extensible

Maven is based on a set of multiple plugins, which can be easily extended or retrieved from a repository on the Internet. Each of this plugin performs a specific task. The tasks to be performed are configured in the pom.xml, which is the configuration file for a module in maven.

platform adaptable

Using maven, you can build different binaries or packages depending on the target platform. You need to describe a given profile. This introduction did not present any example or code. This will be done in the next step.

Friday, 12 September 2008

Overview of Maven

Maven is a tool design to support as many task as possible for the management of a software project.

Its purpose is to provide a simple tool to achieve the following tasks:

  • Builds
  • Documentation
  • Reporting
  • Dependencies
  • SCMs
  • Releases
  • Distribution

A number of good tutorials can be found on maven's guide page.

Archetypes:

In maven there is the possibility to create archetype models of projects. This means that it is possible to create very easily new projects which have a number of templates to start with. This is related to the possibilities of RAILS.

This is performed by issueing the following command:

$ mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Project Object Model: POM

There is a concept of project object model somewhat similar to the ant build files.

An example from the website (see this page):

<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.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven Quick Start Archetype</name>
  <url>http://maven.apache.org</url>
  <dependencies>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
      </dependency>
  </dependencies>
</project>

This model is quite easy to understand.

Project File and Directory Structure

The project file and directory structure depends on the archetype chosen to create a new project. There are means of configuring this, see: http://maven.apache.org/guides/mini/guide-creating-archetypes.html.

The build Life cycle

Each possible tasks (e.g. validate, compile, package) may require other to be performed first. This means that there are dependencies between the tasks (like in ant).

Common tasks
  • mvn compile (compile the code)
  • mvn test (test the functionalities of this project)
  • mvn test-compile (compile test classes for this project)
  • mvn package (package the code of this project)
  • mvn clean (clean the builds and task )
  • mvn site (create a template website for the project)
  • mvn idea:idea (create an IntelliJ IDEA descriptor for the project)
  • mvn eclipse:eclipse (create the project description files for eclipse)
Maven Plugins

There are a number of plugins which can be useful for maven. You can add them to the POM file of the project, see: How_do_I_use_plug-ins

A list of plugins can be found there.

SCM Plugin ( Source Code Management plugin)

One of the many pluging is the SCM plugin which offers useful tasks/goals for interacting with a SCM

External Dependencies

There is also the possibility to configure external dependencies.

Deployment

There are also possibilities of deployment if things are configured. For example, the created distribution can be copied and added to a repository using scp. For this, some information about user names, keys and/or passwords have to be configured.

Documentation

There are also some thing to help in the creation of a documentation site using archetypes. See: guide-site.

Friday, 11 January 2008

Maven

Once I had been using ant, and then I heard about Maven. But what am I supposed to think about Maven. To use maven, we first need to create the basic skeleton of the content of the project. This is performed using in the parent directory of the future project directory: $ mvn archetype:create -DgroupId=org.jaycode.jdream -DartifactId=jdream We can now enter the project directory: $ cd jdream It creates diverse files and directories, in particular a pom.xml, which is a file describing the project and main application and test files. From there we can start coding. But a number of task can be performed (here an extract from the maven tutorial):
  • validate : validate the project is correct and all necessary information is available
  • compile : compile the source code of the project
  • test : test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package : take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test : process and deploy the package if necessary into an environment where integration tests can be run
  • verify : run any checks to verify the package is valid and meets quality criteria
  • install : install the package into the local repository, for use as a dependency in other projects locally
  • deploy : done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
Another interesting feature is the possibility to adapt the pom file for eclipse:
$ mvn eclipse:eclipse
which creates the .classpath and .project files necessary for an eclipse project. One of the very interesting feature of maven is the possibility of creating template projects to simplify the creation of whole projects. It allows for example the possibility to go in the direction of rails some how.