Thursday, October 9, 2014

Maven Alfresco SDK version 2

In a previous post, I talked about the maven alfresco sdk version 1.1.1.  As of Alfresco community 5.0.a, maven alfresco sdk version 2.0.0 beta is out (can also look at this article).  

The two things that pop out right away with the 2.0.0 version is that there is a choice to choose alfresco or share when using the maven archetype, and that springloaded has been integrated for fast development without restarting the server!

Run the following maven command to generate the maven module:
mvn archetype:generate -Dfilter=org.alfresco:

Tweaking the maven template output after creating the Amp-Archetype

Alfresco
Deleted
  • All log4j.properties files.  I am using custom-log4j.properties instead
    • src/main/amp/config/alfresco/module/<artifact id>/log4j.properties
    • src/main/amp/log4j.properties
    • src/test/resources/log4j.properties
    • All the Demo components
Added
  • src/test/resources/alfresco/extension/custom-log4j.properties
Share
Kept
  • src/test/resources/log4j.properties file.  
    • Couldn't use the custom-log4j.properties strategy here, since that only pertains to alfresco (not share)
Deleted
  • src/main/amp/log4j.properties.
  • All sample page, widgets, etc.
Renamed 
  • share-config-custom.xml in src/test/resources/alfresco-webextension/share-config-custom.xml to share-config-custom.xml.sample.  I want to use the one that is packaged inside the amp, over storing it in a shared resource folder.  (i.e. If you want to use the shared resource folder, i.e then you have to configure it in tomcat/shared folder.)
For both Alfresco and Share
In the root maven module folder, since I am using Windows 7, created a runAlfresco/Share.bat file to start alfresco/share, modelling it after run.sh.  You could also of course, specify your IDE to run all this with a maven build instead.

runAlfresco.bat
rem Instructions for starting local Alfresco
rem Make sure to change the following:
rem 1.  SPRINGLOADEDFILE
rem 3.  JAVA_HOME
rem 4.  MAVEN_HOME
rem Alfresco will start on port 8080

set SPRINGLOADEDFILE=C:\Users\jhsu\.m2\repository\org\springframework\springloaded\1.2.0.RELEASE\springloaded-1.2.0.RELEASE.jar

IF EXIST %SPRINGLOADEDFILE% (
  ECHO file exists
) ELSE (
  ECHO file doesn't exist, downloading it
  mvn validate -Psetup
)

set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n
set MAVEN_OPTS=%DEBUG_OPTS% -javaagent:%SPRINGLOADEDFILE% -noverify -Xms256m -Xmx2G -XX:PermSize=300m
set JAVA_HOME=C:\Apps\Java\jdk1.7.0_67
set MAVEN_HOME=C:\Apps\apache-maven-3.2.2
mvn clean integration-test -Pamp-to-war


runShare.bat
rem Instructions for starting local Share
rem Make sure to change the following:
rem 1.  SPRINGLOADEDFILE
rem 3.  JAVA_HOME
rem 4.  MAVEN_HOME
rem Share will start on port 8081

set SPRINGLOADEDFILE=C:\Users\jhsu\.m2\repository\org\springframework\springloaded\1.2.0.RELEASE\springloaded-1.2.0.RELEASE.jar

IF EXIST %SPRINGLOADEDFILE% (
  ECHO file exists
) ELSE (
  ECHO file doesn't exist, downloading it
  mvn validate -Psetup
)

set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=1045,server=y,suspend=n
set MAVEN_OPTS=%DEBUG_OPTS% -javaagent:%SPRINGLOADEDFILE% -noverify
set JAVA_HOME=C:\Apps\Java\jdk1.7.0_67
set MAVEN_HOME=C:\Apps\apache-maven-3.2.2
mvn clean integration-test -Pamp-to-war

For more examples and ideas, I encourage you explore the links provided throughout this blog. What questions do you have about this post? Let me know in the comments section below, and I will answer each one.

2 comments:

I appreciate your time in leaving a comment!