How integrate a jar with a custom action in Alfresco - ant

I've created a custom action with as a eclipse project. I packaged it in a jar and I put it in: alfresco-3.4.d/tomcat/webapps/alfresco/WEB-INF/lib
I started Alfresco and I created a rule with my custom action. When a file is created in this folder then the rule is triggered.
But when I create a file, the unique available type is "content", my custom content types don't show in select list. My problem is I need these custom types.
I have tested starting Alfresco without my jar and all types are availables.
My project structure is wrong?:
src.main.java
-executer
·UrlActionExecuter.java
·UrlActionHandler.java
src.main.resources
-alfresco.extension
·url-actions-context.xml
·web-client-config-custom.xml
·webclient.properties
src.main.webapp
-jsp.actions
·url-action-executer.jsp
or build.xml?:
<?xml version="1.0"?>
<project name="Action Url" default="package" basedir=".">
<property name="project.dir" value="."/>
<property name="build.dir" value="${project.dir}/build"/>
<property name="package.file" value="${build.dir}/Action-url.jar"/>
<path id="class.path">
<dirset dir="${build.dir}" />
<fileset dir="../../lib/server" includes="**/*.jar"/>
</path>
<target name="compile">
<mkdir dir="${build.dir}" />
<javac classpathref="class.path" srcdir="${project.dir}/src" destdir="${build.dir}" />
</target>
<target name="package" >
<jar destfile="${package.file}">
<fileset dir="${build.dir}"/>
</jar>
</target>
</project>
Thanks everybody!

Your custom types should described in the model file and then you should import your model to the alfresco, for example:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="custom_dictionaryBootstrap"
parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/module/mymodule/model/mymodel.xml</value>
</list>
</property>
<property name="labels">
<list>
<value>alfresco/module/mymodule/messages/system</value>
</list>
</property>
</bean>
</beans>

Related

my property file seems not to be implemented by build.xml

I have a problem with properties.
here is content of my build.xml file:
<?xml version="1.0" ?>
<project name="default" default="package">
<target name="init">
<mkdir dir="build/classes" />
<mkdir dir="dist" />
</target>
<property file="${basedir}/localproperties"/>
<property name="javac.debug" value="off"/>
<target name="compile" depends="init" description="Compiles JAVA files">
<echo message="Debug: ${javac.debug}"/>
<javac srcdir="src"
destdir="build/classes"
classpathref="compile.classpath"
debug="${javac.debug}"/>
</target>
<path id="compile.classpath">
<fileset dir="lib" includes="*.jar"/>
</path>
</project>
and here is content of my localproperties file:
javac.debug = on
please note that I have saved localproperties as .xml file and put it into the same directory as build.xml
the problem is that it does not work as the output I get is:
Debug: off
clearly it should be:
Debug: on
please advise.
It should be:
<property file="${basedir}/localproperties.xml"/>
There is no extension assumed by the property task. As long as the content follows the key-value convention, it can be any file extension. But it would be confusing to save as .xml. Just save it as localproperties.properties, or simply local.properties.

Configure Sonar for Delphi with sub-modules

I can get Delphi analysis working on single projects, so the plugin works.
I can get Submodules analysis set up as per my previous question but no delphi analysis is performed.
refer to Configuration of build.xml file for Sonar modules with Ant for reference.
If I include the (I believe) required delphi configuration in the master build file it only works if I include the sonar.sources line.
BUT, when I include that line it is attempting to analyse all delphi code and is ignorning the submodules.
How (assuming it can be done) do I configure this to work or do I have to run each project completely separately?
Master Build File
<?xml version="1.0" encoding="UTF-8"?>
<project name = "EXO" default = "sonar" basedir = "." xmlns:sonar="antlib:org.sonar.ant">
<echo>Root Project</echo>
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="c:/ANT/lib" />
</taskdef>
<property name="sonar.host.url" value="http://localhost:9000" />
<property name="sonar.modules" value="exonet6000/build.xml,CRM/build.xml" />
<target name="sonar">
<sonar:sonar key="EXO.key" version="0.1">
<property key="sonar.sources" value="." />
<property key="sonar.language" value="delph" />
</sonar:sonar>
</target>
</project>
Sub Project Build File
<?xml version="1.0" encoding="UTF-8"?>
<project name="CRM" default="all" basedir=".">
<echo>CRM Module</echo>
<property name="sonar.language" value="delph" />
<property name="sonar.projectKey" value="EXO:CRM" />
<property name="sonar.sources" value="." />
<target name="all" />
</project>

Configuration of build.xml file for Sonar modules with Ant

I am setting up a Sonar project (using the delphi plugin), for simplicity sake assume there are two modules I want to report on.
Each module is in it's own sub-folder and each has it's own build.xml file.
At this point I can successfully run the sonar tasks and generate reports for each module as an independent project.
My problem is with configuring the "master" build.xml file.
The module build.xml file looks like this:
<?xml version="1.0"?>
<project name = "CRM" default = "sonar" basedir = ".">
<!-- Add the Sonar task -->
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="c:/ANT/lib" />
</taskdef>
<target name="sonar">
<property name="sonar.projectKey" value="EXO:CRM" />
<property name="sonar.host.url" value="http://localhost:9000" />
<sonar:sonar workDir="." key="CRM.key" version="0.1" xmlns:sonar="antlib:org.sonar.ant">
<property key="sonar.sources" value="." /> <!-- project sources directories (required) -->
<property key="sonar.language" value="delph" /> <!-- project language -->
<property key="sonar.delphi.codecoverage.excluded" value=".\tests" /> <!-- code coverage excluded directories -->
<property key="sonar.importSources" value="true" /> <!-- should we show sources or not? -->
<property key="sonar.delphi.sources.excluded" value="" /> <!-- excluded directories -->
<property key="sonar.delphi.sources.include" value=".\includes" /> <!-- include directories, "," separated -->
<property key="sonar.delphi.sources.include.extend" value="true" /> <!-- should we extend includes in files? -->
</sonar:sonar>
</target>
</project>
The "Master" build.xml looks like this:
<?xml version="1.0"?>
<project name = "EXO" default = "sonar" basedir = ".">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="c:/ANT/lib" />
</taskdef>
<target name="sonar">
<property name="sonar.modules" value="exonet6000/build.xml,CRM/build.xml" />
<sonar:sonar workDir="." key="EXO.key" version="0.1" xmlns:sonar="antlib:org.sonar.ant">
<!-- project sources directories (required) -->
<property key="sonar.sources" value="." />
<property key="sonar.language" value="delph" />
<property key="sonar.importSources" value="true" />
<property key="sonar.delphi.sources.excluded" value="" />
<property key="sonar.delphi.sources.include" value=".\includes" />
<property key="sonar.delphi.sources.include.extend" value="true" />
</sonar:sonar>
</target>
</project>
It is always scanning all sources (required value) i.e. it is not respecting my modules.
The only way I can get this to work currently is by limiting the source code like this
<property key="sonar.sources" value="./crm/,./exonet6000/" />
I'm sure I must be mis-configuring something obvious here.
EDIT: I have now what I believe is a more consistent set of files based on examples here https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/java-ant-modules
Master build file:
<?xml version="1.0" encoding="UTF-8"?>
<project name = "EXO" default = "sonar" basedir = "." xmlns:sonar="antlib:org.sonar.ant">
<echo>Root Project</echo>
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="c:/ANT/lib" />
</taskdef>
<property name="sonar.host.url" value="http://localhost:9000" />
<property name="sonar.modules" value="exonet6000/build.xml,CRM/build.xml" />
<target name="sonar">
<sonar:sonar key="EXO.key" version="0.1">
</sonar:sonar>
</target>
</project>
and one of the submodule files
<?xml version="1.0" encoding="UTF-8"?>
<project name="CRM" default="all" basedir=".">
<echo>CRM Module</echo>
<property name="sonar.language" value="delph" />
<property name="sonar.projectKey" value="EXO:CRM" />
<property name="sonar.sources" value="." />
<target name="all" />
</project>
At this point the sonar process is completing successfully BUT no actual anlysis is being done. A key point is that I am not seeing the echo of the submodule so I suspect these build tasks are not actually running.
If you look at this sample project using Ant and multimodules, I'd say that you should not specify any property inside the tag in your master build.xml file, and let the submodules specify those properties.
I've got a project with many submodules. My sonar target looks like this:
<target name="sonar" depends="build.dependencies" description="collect code metrics">
<property name="m1" value="a/build.xml,b/build.xml,c/build.xml,d/build.xml"/>
... more properties defining modules...
<property name="sonar.modules" value="${m1},${m2},${m3},${m4},${m5},${m6}..."/>
<property name="sonar.projectName" value="MyProject"/>
<sonar:sonar key="my:project" version="${version}" xmlns:sonar="antlib:org.sonar.ant">
</sonar:sonar>
</target>
No property definitions in the sonar:sonar task at all, and it is working as I want it to.
Sources are defined in the submodule build.xml files. (Actually, in a base-build.xml that all our build.xml files include... but that's an Ant thing not directly related to Sonar.)

sorting as well as removing duplicacy

<?xml version="1.0"?>
<project name="sortlist11" default="sortlist11">
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
<property name="my.list" value="z,y,x,w,v,u,t" />
<property name="my.list1" `value="5,3,6,1,8,4,6" `/>
<target name="sortlist11">
<sortlist property="my.sorted.list" value="${my.list}" delimiter="," />
<sortlist property="my.sorted.list1" value="${my.list1}" delimiter="," />
<echo message="${my.sorted.list}" />
<echo message="${my.sorted.list1}" />
</target>
</project>
here second echo print 1,3,4,5,6,6,8 but how can i remove redundancy?
Every language running in JVM via Bean Scripting Framework may be used in ant with full access to the ant api. Here's a solution with Groovy for your problem =
<project>
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy"/>
<property name="my.list" value="z,y,x,w,v,u,t"/>
<property name="my.list1" value="5,3,6,1,8,4,6"/>
<groovy>
properties.'my.sorted.list' = properties.'my.list'.split(',').sort().toString()
properties.'my.sorted.list1' = properties.'my.list1'.split(',').toList().unique().sort().toString()
</groovy>
<echo>
$${my.sorted.list} => ${my.sorted.list}
$${my.sorted.list1} => ${my.sorted.list1}
</echo>
</project>

Ant + Coldspring

I am working with the new cfbuilder and using ANT to push my code to my dev server. One issue that keeps cropping up is when I make changes to my beans.xml file my ant build throws an exception on my beans.xml file.
This is the exception that I get:
BUILD FAILED
C:\workingcopies\bpmMag\config\beans.xml:3: Unexpected element "{}beans" {antlib:org.apache.tools.ant}beans
Here is my build file:
<?xml version="1.0" encoding="UTF-8"?>
<project name="build" default="" basedir=".">
<description>
A description of what this build file does
</description>
<!-- Location of working Copy -->
<property name="workingCopy" value="C:\workingcopies\bpmMag" />
<!-- Location of testing server -->
<property name="testServer" value="Z:\www\dev7.devstation\htdocs" />
<!-- Test Target -->
<target name="test">
<copy todir="${testServer}">
<fileset dir="${workingCopy}">
<exclude name="coldspring/**"/>
<exclude name="**/*.project"/>
<exclude name="settings.xml"/>
<exclude name=".settings/**"/>
<exclude name="build.xml"/>
</fileset>
</copy>
</target>
Here is my beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<!-- Advice Beans -->
<bean id="AdviceDAO" class="com.model.advice.dao.AdviceDAO">
<constructor-arg name="dsn"><value>${dsn}</value></constructor-arg>
</bean>
<bean id="AdviceGateway" class="com.model.advice.gateway.AdviceGW">
<constructor-arg name="dsn"><value>${dsn}</value></constructor-arg>
</bean>
<bean id="AdviceService" class="com.model.advice.service.AdviceSV">
<constructor-arg name="adviceDAO">
<ref bean="adviceDAO"/>
</constructor-arg>
<constructor-arg name="adviceGateway">
<ref bean="adviceGateway"/>
</constructor-arg>
</bean>
</beans>
Is that your entire build file? Because it's missing the closing project tag
I copied your beans.xml and build.xml, added the end project tag, set up a simulation set of directories, and it worked as expected for me (i.e. no {} beans.... error)

Resources