Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to speed up Alfresco Share development

I'm developing and performing some customization on Share. My IDE is Eclipse Juno and workspace is made up of the next elements:

  • alfresco web project
  • extensions Java project
  • share web project

Both alfresco and share web projects are deployed in separate Tomcat instances, this way I can slightly speed up my development tasks by restarting only the Tomcat instance where Share is deployed.

My extensions Java project has the same structure as the Eclipse project proposed by Alfresco. Y the provided Ant tasks for compiling, compressing JavaScript files, packaging and deploying the resultant JAR file in Tomcat.

I'm developing some new JavaScript client-side widgets, which means every time I make a change I have to stop Tomcat, launch Ant build script and start again so as I have to do it very often, you can guess what a pain it is becoming. I was just wondering if there exist any way to speed up development tasks on Share. How do Alfresco developers team do it? What kind of environment do they set up?

I was thinking about creating a new Ant target which hot deploys extension project's content into deployed Share web project, taking into account paths of course; that mechanism must allow the reverse operation by the way. Would that be viable? The idea would be to have a similar deploy mechanism as when you develop regular web projects: when you make any change you just push the "Publish" button and the changes are populated into the server.

I would like to know some tips and ideas, specifically from Alfresco developers team if possible.

PS: I have already read https://forums.alfresco.com/en/viewtopic.php?f=47&t=44850 and https://forums.alfresco.com/en/viewtopic.php?f=48&t=18749.

like image 793
Alejandro García Seco Avatar asked Jan 11 '13 14:01

Alejandro García Seco


2 Answers

Two things that speeds up things a lot:

  • Invest in a jrebel license for class reloading without server restart http://zeroturnaround.com/software/jrebel/

  • Construct ant tasks that copy webscripts to the target folder and reloads webscripts with curl if necessary.

Example of a task that reloads an Alfresco Share webscript:

<target name="deploy-share-webscripts" depends="Share: Copy files" description="Refreshes the list of webscripts">
    <exec executable="curl">
    <arg value="-d"/>
    <arg value="reset=on"/>
    <arg value="http://admin:admin@${share.web.url}/page/console?reset=webscripts"/>
    </exec>
</target>

Appending the copying part of the ant task (the src-dirs are declared as properties in the beginning of the buildfile):

    <echo message="- Copying java classes" />
    <copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
        <fileset dir="${warTargetJavaDir}" />
    </copy>

    <echo message="- Copying resource files" />
    <copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
        <fileset dir="${warSrcResourcesDir}" >
            <include name="**/model/*"/>
            <include name="**/templates/**/*"/>
            <include name="**/custom-model-context.xml"/>
            <include name="**/web-client-config-custom.xml"/>
            <include name="**/webclient.properties"/>
            <include name="**/aka-model-resourcebundle*"/>
            <include name="log4j.properties"/>
        </fileset>
    </copy>

    <echo message="- Copying resource files from amp into war for quick deployment." />
    <copy todir="${warWebappTargetClasses}" overwrite="false" verbose="true">
        <fileset dir="${projectAmpResourcesSrcDir}" />
        <fileset dir="${projectAmpClassesDir}" />

        <fileset dir="${listmanagerAmpResourcesSrcDir}" />

    </copy>

    <echo message="- Copying config files from amp into war for quick deployment." />
    <copy todir="${warWebappTargetClasses}\alfresco\module\Project-amp\" overwrite="false" verbose="true">

        <fileset dir="${projectAmpConfigSrcDir}" />


    </copy>
</target>

I use the maven alfresco lifecycle http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven for my setup, which also speeds up things. I sure a lot can be added to this topic.

like image 196
billerby Avatar answered Nov 10 '22 21:11

billerby


You can avoid copying the webscripts to the tomcat by configuring additional paths for tomcats shared classloader. This is a setting in tomcat/conf/catalina.properties. I set this directly to the projects source directory so there is no need for the compile step.

shared.loader=${catalina.home}/shared/classes,${catalina.home}/shared/lib/*.jar,\
/path/to/my/dashlet/src/main/resources,\

I also have the following settings in shared/classes/alfresco/web-extension/share-config-custom.xml to enable automatic refresh of templates and webscripts.

<alfresco-config>
    <!-- Global config section -->
    <config replace="true">
        <flags>
            <!-- Developer debugging setting - DEBUG mode for client scripts in the browser -->
            <client-debug>true</client-debug>

            <!-- LOGGING can be toggled at runtime when in DEBUG mode (Ctrl, Ctrl, Shift, Shift).
                 This flag automatically activates logging on page load. -->
            <client-debug-autologging>false</client-debug-autologging>
        </flags>
    </config>

    <config evaluator="string-compare" condition="WebFramework">
        <web-framework>
            <!-- Autowire Runtime Settings -->
            <autowire>
                <!--
                    Developers can set mode to 'production' or 'development' (to disable; SpringSurf caches,
                    FreeMarker template caching and Rhino JavaScript compilation.)
                -->
                <mode>development</mode>
            </autowire>
        </web-framework>
    </config>
</alfresco-config>
like image 3
Jörn Horstmann Avatar answered Nov 10 '22 22:11

Jörn Horstmann