Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cyclic linking detected in Maven build(Xtext chooses to process files in a way that make the Maven build fail)
Cyclic linking detected in Maven build [message #1773531] Thu, 28 September 2017 22:49 Go to next message
Miguel Jimenez is currently offline Miguel JimenezFriend
Messages: 40
Registered: July 2015
Member
Hi,
I've been reading about cyclic linking issues with Xtext projects. Specifically from:
1. Cyclic linking problems in builds of an incquery project
2. Cyclic linking detected when building in maven

I'm working on this DSL (here is the Xtext project). I created a local example and it works well
in an Eclipse plug-in. However, in a Maven project the build fails because of a cyclic link.
This is the Maven output:

[INFO] Starting validation for input: 'Client.amelia'
[INFO] Starting validation for input: 'Deployment.amelia'
[ERROR] ERROR:<validation errors because of failed Java generation>
[INFO] Starting validation for input: 'Server.amelia'
[INFO] Starting validation for input: 'FraSCAti.amelia'
[ERROR] ERROR:Cyclic linking detected : ExtensionDeclaration.element->ExtensionDeclaration.element (file:/.../FraSCAti.amelia line : 5 column : 10)
[ERROR] ERROR: <validation errors because of failed Java generation>
[INFO] Starting validation for input: 'Java1_6u23.amelia'


A type in my language may include and/or depend on another type. That is an extension declaration.
Types are defined in separate files. This issue is very similar to the one described in the incquery
bug report (link 1). I followed their recommendation to see if it works, and it did. That is, renaming the
files to affect the other on which Xtext process them. The following is the Maven output corresponding
to the same project, but renaming the files to avoid the cyclic linking:

[INFO] Starting validation for input: 'A_Java1_6u23.amelia'
[INFO] Starting validation for input: 'B_FraSCAti.amelia'
[INFO] Starting validation for input: 'C_Server.amelia'
[INFO] Starting validation for input: 'D_Client.amelia'
[INFO] Starting validation for input: 'E_Deployment.amelia'
...
[INFO] Starting generator for input: 'A_Java1_6u23.amelia'
[INFO] Starting generator for input: 'B_FraSCAti.amelia'
[INFO] Starting generator for input: 'C_Server.amelia'
[INFO] Starting generator for input: 'D_Client.amelia'
[INFO] Starting generator for input: 'E_Deployment.amelia'


The dependencies in this sample project are:

B_FraSCAti.amelia ---includes---> A_Java1_6u23.amelia
C_Server.amelia ---depends on---> B_FraSCAti.amelia
D_Client.amelia ---depends on---> B_FraSCAti.amelia
D_Client.amelia ---depends on---> C_Server.amelia
E_Deployment.amelia ---includes---> B_FraSCAti.amelia, C_Server.amelia, D_Client.amelia


I'm sure the problem is including A_Java1_6u23.amelia into B_FraSCAti.amelia, but I don't know why.
If I remove that inclusion, the build succeeds. Also, if I remove the dependencies
C_Server.amelia & D_Client.amelia on B_FraSCAti.amelia, it works.

My questions are:

- Is this happening because I'm doing something wrong (e.g., scoping) or is this a bug?
- Is there a way to order the files before Xtext process them? the problem here, I guess, is that I have to somehow process them in order to compute the order.

[Updated on: Fri, 29 September 2017 01:37]

Report message to a moderator

Re: Cyclic linking detected in Maven build [message #1773537 is a reply to message #1773531] Fri, 29 September 2017 04:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi usually this is an implementation error.
But one never knows

Do you access any references in name providers? Or resourcedescrptionstrategy
Do you have places in scoping where you might up scoping the same reference during scoping a reference
Looks like it is the second one. It looks like on the order of resolving subsystems
What you exactly want to achieve with this scoping adaption?
Implicit imports for subsystems?

If yes you could simply use the node model to create an import and use Xtext defaults mechanism for shortening the names


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 29 September 2017 04:37]

Report message to a moderator

Re: Cyclic linking detected in Maven build [message #1773585 is a reply to message #1773537] Fri, 29 September 2017 17:40 Go to previous messageGo to next message
Miguel Jimenez is currently offline Miguel JimenezFriend
Messages: 40
Registered: July 2015
Member
Hi,
I commented out the following things, but it continued failing:
- the use of AmeliaImportSectionNamespaceScopeProvider from the runtime module
- code for looking for candidates in cross-references in the AmeliaScopeProvider
- the qualified name provider customization

I'm not using any resource description strategy.
I'm using AmeliaImportSectionNamespaceScopeProvider to import subsystems in the
generated classes, when they're included in the model. But it seems that this not causing
the problem.

I'm out of ideas :/
Re: Cyclic linking detected in Maven build [message #1773587 is a reply to message #1773585] Fri, 29 September 2017 18:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
i cant follow you. if you dont follow references there cannot be cycling linking. thus it cannot be what you really commented out the stuff.
i gonna have a look when git cloned your "feeled" terabyte big repo


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cyclic linking detected in Maven build [message #1773589 is a reply to message #1773587] Fri, 29 September 2017 18:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
where can i find the test project?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cyclic linking detected in Maven build [message #1773592 is a reply to message #1773589] Fri, 29 September 2017 18:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
can be reproduced with pure hjava/unit test

public class Main {

public static void main(String[] args) throws IOException {
Injector i = new AmeliaStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet resourceSet = i.getInstance(ResourceSet.class);
String baseDir = "/home/dietrich/git/amelia/examples/docker-hello-world/src/main/amelia/org/amelia/dsl/examples/ubuntu/containers/";
Resource r1 = resourceSet.getResource(URI.createURI(baseDir+"Helloworld.amelia"), true);
Resource r2 = resourceSet.getResource(URI.createURI(baseDir+"Deployment.amelia"), true);
Resource r3 = resourceSet.getResource(URI.createURI(baseDir+"DockerCE.amelia"), true);
r1.load(null);
r2.load(null);
r3.load(null);
IResourceValidator resourceValidator = i.getInstance(IResourceValidator.class);
resourceValidator.validate(r1, CheckMode.NORMAL_AND_FAST, new CancelIndicator() {

@Override
public boolean isCanceled() {
return false;
}
});
System.out.println(r1.getErrors());
System.out.println(r2.getErrors());
System.out.println(r3.getErrors());

}

}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cyclic linking detected in Maven build [message #1773595 is a reply to message #1773592] Fri, 29 September 2017 19:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
=> you can debug and see the inferrer is the problem.
you do bad stuff at

org.amelia.dsl.jvmmodel.AmeliaJvmModelInferrer.includedVariableDecl(Subsystem, boolean, boolean, boolean)
there you traverse the included subsystems

it looks like you cannot traverse non xbase reference in the inferrer. i am not sure of this is a bug
a ticket at github.com/eclipse/xtext-extras would be nice.

i have a kind a dejavu but cannot find anything (exisitng bug etc)



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cyclic linking detected in Maven build [message #1773596 is a reply to message #1773595] Fri, 29 September 2017 19:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
if i do resolve first and validate second its no problem

r1.load(null);
r2.load(null);
r3.load(null);
EcoreUtil2.resolveAll(r1);
EcoreUtil2.resolveAll(r2);
EcoreUtil2.resolveAll(r3);
IResourceValidator resourceValidator = i.getInstance(IResourceValidator.class);
resourceValidator.validate(r1, CheckMode.NORMAL_AND_FAST, new CancelIndicator() {

@Override
public boolean isCanceled() {
return false;
}
});

it has to do with how you traverse the model in the validator between the file


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cyclic linking detected in Maven build [message #1773597 is a reply to message #1773596] Fri, 29 September 2017 19:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
did some more digging and maybe this works as workaround

def private void internalFindDependentTasksRec(EObject e, Set<EObject> set) {
if (!set.add(e))
return;
val dependencies = if (e instanceof Subsystem)
(e.eContainer as Model).extensions.declarations.map[d|d.element]
else if (e instanceof RuleDeclaration)
e.dependencies
for (t : dependencies) {
EcoreUtil.resolveAll(t.eResource)
internalFindDependentTasksRec(t, set)
}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cyclic linking detected in Maven build [message #1773598 is a reply to message #1773596] Fri, 29 September 2017 19:45 Go to previous messageGo to next message
Miguel Jimenez is currently offline Miguel JimenezFriend
Messages: 40
Registered: July 2015
Member
I'm very sorry about that repo being so big! I have the Eclipse update site in the gh-pages branch.

Wow, thank you very much for all this. You're right, I recursively traverse the models in the inferrer (didn't remember that before).
That must be it. I'll follow your recommendations and let you know if its a bug or I'm doing (more) bad stuff.

Thank you again.
Re: Cyclic linking detected in Maven build [message #1773671 is a reply to message #1773598] Mon, 02 October 2017 16:28 Go to previous message
Miguel Jimenez is currently offline Miguel JimenezFriend
Messages: 40
Registered: July 2015
Member
Thank you very much Christian, the workaround works perfectly.
Previous Topic:IGrammarAccess cannot be resolved. It is indirectly access
Next Topic:exception from generator
Goto Forum:
  


Current Time: Tue Mar 19 10:39:09 GMT 2024

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

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

Back to the top