Ale*_*eco 5 share development-environment alfresco
我正在开发并在Share上执行一些自定义.我的IDE是Eclipse Juno,工作区由下一个元素组成:
露天和共享Web项目都部署在单独的Tomcat实例中,这样我只需重新启动部署了Share的Tomcat实例,就可以略微加快我的开发任务.
我的扩展Java项目与Alfresco提出的Eclipse项目具有相同的结构.提供的Ant任务用于编译,压缩JavaScript文件,在Tomcat中打包和部署生成的JAR文件.
我正在开发一些新的JavaScript客户端小部件,这意味着每次我做出更改时都必须停止Tomcat,启动Ant构建脚本并重新开始,因为我必须经常这样做,你可以猜到它是多么痛苦正变成.我只是想知道是否有任何方法可以加速Share上的开发任务.Alfresco开发团队如何做到这一点?他们建立了什么样的环境?
我正在考虑创建一个新的Ant目标,它将扩展项目的内容热部署到已部署的Share Web项目中,同时考虑到路径; 该机制必须允许反向操作.那可行吗?我们的想法是拥有与开发常规Web项目时类似的部署机制:当您进行任何更改时,只需按"发布"按钮,更改就会填充到服务器中.
我想了解一些技巧和想法,特别是Alfresco开发团队的可能性.
PS:我已经阅读了https://forums.alfresco.com/en/viewtopic.php?f=47&t=44850和https://forums.alfresco.com/en/viewtopic.php?f=48&t=18749.
两件事可以加速很多事情:
投资jrebel许可证进行类重装而无需重启服务器http://zeroturnaround.com/software/jrebel/
构造将Web脚本复制到目标文件夹的ant任务,并在必要时使用curl重新加载webscripts.
重新加载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>
Run Code Online (Sandbox Code Playgroud)
附加ant任务的复制部分(src-dirs在构建文件的开头声明为属性):
<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>
Run Code Online (Sandbox Code Playgroud)
我使用maven alfresco生命周期http://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven进行设置,这也加快了速度.我确定可以在这个主题中加入很多内容.
嗯,这是一个 100% 正常工作的解决方案,正如我所预期的那样。我在 @erik-b 和 @jorn-horstmann 的回答后想到了这个,并考虑了我读过的一些帖子。
所以基本上我有下一个 Ant 目标,它热部署我的共享扩展 Java 项目的内容:
<!--
Hot copy individual files into appropriate deployment folder (e.g. $TOMCAT_HOME/webapps/share)
-->
<target name="hotdeploy-tomcat-share" depends="clean, prepare, build-jar" description="Hot copy individual files into appropriate deployment folder (e.g. $TOMCAT_HOME/webapps/share)">
<echo message="Generating and deploying JAR file with custom configuration files" />
<jar destfile="${dist.dir}/${jar.name}">
<!-- Only including configuration XML files such as share-config-custom.xml -->
<fileset dir="${build.jar.dir}" includes="**/META-INF/*.xml" />
</jar>
<copy todir="${tomcat.share.deployment.path}/WEB-INF/lib">
<fileset file="${dist.dir}/${jar.name}" />
</copy>
<echo message="Hot deploying Share files" />
<copy todir="${tomcat.share.deployment.path}/WEB-INF/classes" includeEmptyDirs="false">
<fileset dir="${build.jar.dir}">
<patternset refid="hotdeploy-tomcat-patternset" />
</fileset>
</copy>
</target>
Run Code Online (Sandbox Code Playgroud)
必须禁用自动重新加载模块功能,否则每次执行上述 Ant 目标时,Tomcat 都会重新加载 Share 和部署的其他 Web 应用程序。另外,我相信也可以在 $TOMCAT_HOME/shared/ 目录中进行热部署,但我还没有尝试过。
我用于开发扩展的 Java 项目是这个模型项目:http://code.google.com/p/share-extras/wiki/SampleProject。有完整的构建脚本以及所需的其他目标。
我也在我的 share-config-custom.xml 中使用它:
<!-- Global config section -->
<config replace="true">
<flags>
<!--
Developer debugging setting to turn on DEBUG mode for client scripts in the browser
-->
<client-debug>true</client-debug>
<!--
LOGGING can always 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>
<!-- SpringSurf Autowire Runtime Settings -->
<!--
Developers can set mode to 'development' to disable; SpringSurf caches,
FreeMarker template caching and Rhino JavaScript compilation.
-->
<autowire>
<!-- Pick the mode: "production" or "development" -->
<mode>development</mode>
</autowire>
<!-- Allows extension modules with <auto-deploy> set to true to be automatically deployed -->
<module-deployment>
<mode>manual</mode>
<enable-auto-deploy-modules>true</enable-auto-deploy-modules>
</module-deployment>
</web-framework>
</config>
Run Code Online (Sandbox Code Playgroud)
例如,最后一个 XML 片段可以避免在 FTL 页面上执行任何更改后刷新网页脚本。
我还使用 JRebel 进行了一些测试,但根据我的经验,我会说它对共享开发没有多大帮助。
接下来的文章中还有一些有趣的内容:
http://blogs.alfresco.com/wp/kevinr/2010/04/07/developer-tips-for-alfresco-share-33/
http://techblog.zabuchy.net/2012/debugging-javascript-in-alfresco/
希望它对其他人有帮助。