cancel
Showing results for 
Search instead for 
Did you mean: 

Use external code in the Module AMP

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

I would like to use code inside another projet. I have some problems to generate my module.

The Eclipse projets
Projet_common (contains Tools.java)
Module_Alfresco_Custom

build.xml (working)


<target name="compile">
  <mkdir dir="${build.dir}/classes" />
  <javac classpathref="class.path" srcdir="${project.dir}/source/java" destdir="${build.dir}/classes">
  </javac>
</target>

build.xml (take code inside the Projet_common, not working)

<property name="src_Common" location="../Projet_common/src" />
<target name="compile">
  <mkdir dir="${build.dir}/classes" />
  <javac classpathref="class.path" srcdir="${src_Common}:${project.dir}/source/java" destdir="${build.dir}/classes">
  </javac>
</target>

Error message

Apache Ant version 1.7.1 compiled on June 27 2008

compile:
    [mkdir] Skipping G:\custom\doc_temp\03_Projet_GED\06_Code\Java\Module_Alfresco_Custom\build\classes because it already exists.
    [javac] ch\custom\common\workers\Tools.java added as ch\custom\common\workers\Tools.class doesn't exist.

BUILD FAILED
G:\custom\doc_temp\03_Projet_GED\06_Code\Java\Module_Alfresco_Custom\build.xml:28: G:\custom\doc_temp\03_Projet_GED\06_Code\lib\server not found.
   at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:434)
   at org.apache.tools.ant.types.FileSet.iterator(FileSet.java:69)
   at org.apache.tools.ant.types.resources.Union.getCollection(Union.java:110)
   at org.apache.tools.ant.types.resources.Union.getCollection(Union.java:90)
   at org.apache.tools.ant.types.resources.BaseResourceCollectionContainer.cacheCollection(BaseResourceCollectionContainer.java:250)
   at org.apache.tools.ant.types.resources.BaseResourceCollectionContainer.iterator(BaseResourceCollectionContainer.java:126)
   at org.apache.tools.ant.types.Path.iterator(Path.java:693)
   at org.apache.tools.ant.types.Path.iterator(Path.java:687)
   at org.apache.tools.ant.types.resources.Union.getCollection(Union.java:110)
   at org.apache.tools.ant.types.resources.Union.list(Union.java:69)
   at org.apache.tools.ant.types.Path.list(Path.java:359)
   at org.apache.tools.ant.types.Path.addExisting(Path.java:330)
   at org.apache.tools.ant.types.Path.addExisting(Path.java:318)
   at org.apache.tools.ant.types.Path.concatSpecialPath(Path.java:563)
   at org.apache.tools.ant.types.Path.concatSystemClasspath(Path.java:515)
   at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.getCompileClasspath(DefaultCompilerAdapter.java:153)
   at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.setupJavacCommandlineSwitches(DefaultCompilerAdapter.java:183)
   at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.setupModernJavacCommandlineSwitches(DefaultCompilerAdapter.java:321)
   at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.setupModernJavacCommand(DefaultCompilerAdapter.java:368)
   at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:48)
   at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1065)
   at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:882)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
   at org.apache.tools.ant.Task.perform(Task.java:348)
   at org.apache.tools.ant.Target.execute(Target.java:357)
   at org.apache.tools.ant.Target.performTasks(Target.java:385)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
   at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
   at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
   at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
   at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)

Total time: 1 second

Thanks
2 REPLIES 2

dranakan
Champ on-the-rise
Champ on-the-rise
Need to specify another classpathref


    <!– Path to use library in Common code–>
   <path id="classpath.Common">
      <fileset dir="../Common/lib" includes="**/*.jar" />
   </path>

   <!– Path to use library –>
   <path id="class.path">
      <dirset dir="${build.dir}" />
      <fileset dir="../../lib/server" includes="**/*.jar" />
   </path>
   
   <!– Compile Common code–>
   <target name="compileCommon">
      <mkdir dir="${build.dir}/classes" />
      <javac classpathref="classpath.Common" srcdir="${src_Common}" destdir="${build.dir}/classes" debug="true"/>
   </target>

   <target name="compile" depends="compileCommon">
      <mkdir dir="${build.dir}/classes" />
      <javac classpathref="classpath" srcdir="${project.dir}/source/java" destdir="${build.dir}/classes" />
   </target>

dranakan
Champ on-the-rise
Champ on-the-rise
The debug was not working inside the external code…

I have added (previous post updated).
debug="true"/> 

Don't forget to clean projects (Ecplise menu : "Project", "Clean…")