I am generating some files by using different Acceleo templates defined into a *.mtl file.
At the top op these files I need to write something like:
#-----------------------------------------------------------------------------
# Project automatically generated by XXX at (add timestamp here)
#-----------------------------------------------------------------------------
How could I generate this timestamp dynamically each time I generate the files?
Thanks!
Edit: I solved this as described below.
Just after the module
declaration, add query
declarations:
[module generate('platform:/resource/qt48_model/qt48_xmlschema.xsd') ]
[comment get timestamp/]
[query public getCurrentTime(c : OclAny) : String =
invoke('org.eclipse.acceleo.qt_test_api.generator.common.GenerationSupport', 'getCurrentTime()', Sequence{}) /]
Then, create a class called GenerationSupport
and add a method called getCurrentTime()
:
package org.eclipse.acceleo.qt_test_api.generator.common;
import java.sql.Timestamp;
public class GenerationSupport {
public String getCurrentTime(){
java.util.Date date = new java.util.Date();
Timestamp ts = new Timestamp(date.getTime());
return ts.toString();
}}