Showing posts with label maven2. Show all posts
Showing posts with label maven2. Show all posts

Saturday, February 6, 2010

Setup of development on eXoJCR 1.12

Short intro in preparations to eXo JCR development.
(repost of setup, adopted to eXoJCR 1.12)

eXo and GateIn products development based on Maven2 project management. Easiest way to start the development it's to setup right Maven2 project (POM) and its dependencies.

Prerequisites
  • Java 5 (add JDK executables to the PATH on your system)
  • Maven2 (add Maven2 2.2.1 or higher executable to the PATH on your system, )
  • Eclipse (optional)
Creating project (POM)

We say that our project name is my-jcrapp (use your name instead of this dummy one).

In empty folder run Maven command:

For Java project:
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.mycompany.exojcr -DartifactId=my-jcrapp
For Groovy enabled project:
mvn archetype:generate -DarchetypeGroupId=org.codehaus.groovy.maven.archetypes -DarchetypeArtifactId=gmaven-archetype-basic -DgroupId=com.mycompany.exojcr -DartifactId=my-jcrapp

The commend ask for a project version Define value for version: 1.0-SNAPSHOT: :
Press Enter or type your version, it then ask for confirmation - press Enter to agree.

This command creates the project folder named my-jcrapp with ready to use files structure. There are pom.xml, src folder with place for application code and tests. Project model (pom.xml) contains dependencies declaration, here is JUnit only (and Groovy runtime if you're groovy :) ).

eXo JCR dependency

Next, add eXo JCR dependency to the POM.
eXoJCR jar files lives on JBoss Maven2 repository. Add JBoss repo to Maven2 local repositories list: or into settings.xml or directly in the your project POM (add repositories element after the dependencies).
<repositories>
<repository>
<id>exo-int</id>
<name>jboss.org repository</name>
<url>http://repository.jboss.com/maven2 </url>
<layout>default</layout>
</repository>
</repositories>
Now add the JCR core dependency:
<dependency>
<groupid>org.exoplatform.jcr</groupid>
<artifactid>exo.jcr.component.core</artifactid>
<version>1.12.0-GA</version>
<scope>compile</scope>
</dependency>
If you need JCR Ext features then add this dependency (in fact you need only Ext one, it will points JCR core itself):
<dependency>
<groupid>org.exoplatform.jcr</groupid>
<artifactid>exo.jcr.component.ext</artifactid>
<version>1.12.0-GA</version>
<scope>compile</scope>
</dependency>
And it's ready to build!

Build project

Run given command and wait till eXo JCR with its dependencies will be downloaded to your local Maven2 repo (~25Mb):
mvn clean compile
and be sure you see BUILD SUCCESSFUL at the end of this execution.

If something goes wrong with the build check all step from the begin and proxy.

Successful? Voi-la, you're ready to eXo JCR development!


Eclipse IDE setup read there.

Several notes about Groovy support in Eclipse.
I have used Groovy-Eclipse plugin of version 2.0.0 (update site). After generation from maven2 project (via mvn eclipse:eclipse) and import into Eclipse I found that Groovy-Eclipse doesn't recognize the project as a Groovy project and as a result the plugin has no sense for development.
Trouble can be fixed by Eclipse project file (.project) manual editing. Add the next line to natures element

<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>

and refresh the project.
Another issue with the plugin it's switch to Groovy 1.6.x compiler. Why 1.6? eXoJCR 1.12 bundled with Groovy 1.6.5, it's better to use closer version in IDE.

Enjoy!

Thursday, July 30, 2009

Setup eXo JCR development environment

Short intro in preparations to eXo JCR development.

All eXo products development based on Maven2 project management. So, easiest way to start the development with eXo it's to setup right Maven2 project and its dependencies.

eXo Portal (and ECM, DMS, WCM, CS, KS etc) developers can find lot of useful resources on eXo wiki:
All thing from there are actual for eXo JCR development also... but there is easiest way - just setup a right POM.

Prerequisites
  • Java 5 (add JDK executables to the PATH on your system)
  • Maven2 (add Maven2 executables to the PATH on your system, )
  • Eclipse (optional)
Creating project (POM)

We say that our project name is my-jcrapp (use your name instead of this dummy one).

In empty folder run Maven command:
mvn archetype:create -DgroupId=com.mycompany.exojcr -DartifactId=my-jcrapp
This command creates the project folder named my-jcrapp with ready to use files structure. There are pom.xml, src folder with place for application code and tests. Project model (pom.xml) contains dependencies declaration, here is only JUnit now.

eXo JCR dependency

So, you have to add eXo JCR dependency to the POM...

but... eXo JCR jar files don't live on central Maven2 repository, they are on eXoPlatform one.
Add eXo repo to Maven2 local repositories list: or into settings.xml or directly in the your project POM (add repositories element after the dependencies).
<repositories>
<repository>
<id>exo-int</id>
<name>exoplatform.org repository</name>
<url>http://maven2.exoplatform.org/rest/maven2 </url>
<layout>default</layout>
</repository>
</repositories>
Now add the JCR core dependency:
<dependency>
<groupid>org.exoplatform.jcr</groupid>
<artifactid>exo.jcr.component.core</artifactid>
<version>1.11.2</version>
<scope>compile</scope>
</dependency>
If you need JCR Ext features then add this dependency (in fact you need only Ext one, it will points JCR core itself):
<dependency>
<groupid>org.exoplatform.jcr</groupid>
<artifactid>exo.jcr.component.ext</artifactid>
<version>1.11.2</version>
<scope>compile</scope>
</dependency>
And it's ready to build!

Build project

Run given command and wait till eXo JCR with its dependencies will be downloaded to your local Maven2 repo (~25Mb):
mvn clean compile
and be sure you see BUILD SUCCESSFUL at the end of this execution.

If something goes wrong with the build check all step from the begin and proxy.

Successful? Voi-la, you're ready to eXo JCR development!

IDE

To write real code you need any of good Java IDE.
We're using Eclipse, the best one :). But NetBeans or Intellij Idea so good also.
Those short instructions are actual for any IDE, but I assumed that the IDE supports import of existing sources.

The best way it's to load just created my-jcrapp Maven2 project to the IDE.
Maven2 helps great with this task. Create Eclipse project files by the command:
mvn eclipse:eclipse
Then open Eclipse and Import the project as an existing project.


Add local Maven2 repo path variable M2_REPO to Java build classpath:


Now the project is ready to development in Eclipse:


Good luck!