Cyclic linking detected in Maven build [message #1773531] |
Thu, 28 September 2017 22:49 |
Miguel Jimenez 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 |
|
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 #1773592 is a reply to message #1773589] |
Fri, 29 September 2017 18:32 |
|
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 |
|
=> 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 |
|
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 |
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02895 seconds