Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Access to target folder from within Acceleo generation
Access to target folder from within Acceleo generation [message #1817628] Tue, 26 November 2019 22:57 Go to next message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
I am trying to work out if a file exists or not, before I can decide if/how I can generate its content.

I thought I can develop a Java service that checks if the file exists on disk. The problem however is that that file path in the [file someFilePath] block is a relative path. The absolute path depends on the base path which is set in the main generate.java class.

How can I get hold of this base path, so I can work out the complete file path of a file to be generated?

I saw this old post https://www.eclipse.org/forums/index.php/t/513117/, but this does not seem to have this problem.

In my case, the base path can be anything the user specifies, and is not relative to the path of the Eclipse project where the model exists.

[Updated on: Tue, 26 November 2019 22:59]

Report message to a moderator

Re: Access to target folder from within Acceleo generation [message #1817638 is a reply to message #1817628] Wed, 27 November 2019 06:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

Model transformation tools transform models. If you have an outer system control issue, I suggest you wrap your transformation problem within a system control caller, probably coded in Java. You might pass the relevant system state to to your transformation as a further model.

Regards

Ed Willink
Re: Access to target folder from within Acceleo generation [message #1817910 is a reply to message #1817638] Tue, 03 December 2019 03:14 Go to previous message
Jad El-khoury is currently offline Jad El-khouryFriend
Messages: 61
Registered: August 2015
Member
Hi,

This question concerns the configuration of the program (Acceleo) that runs the model transformation, and not necessarily related to the model transformation itself. For what it is worth for others facing similar question, I ended up passing the targetFolder as a parameter to the main Acceleo model, by modifying the java method, as such

    public Generate(EObject model, File targetFolder,
            List<? extends Object> arguments) throws IOException {
        //initialize(model, targetFolder, arguments);
        initialize(model, targetFolder, List.of(targetFolder.getAbsolutePath()));
    }
Previous Topic:[Acceleo] standalon vs plugin execution time
Next Topic:Error in running Acceleo project
Goto Forum:
  


Current Time: Sun Dec 01 17:44:00 GMT 2024

Powered by FUDForum. Page generated in 0.02497 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top