Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Dynamic profile not detected on second maven execution
Dynamic profile not detected on second maven execution [message #1742858] Thu, 08 September 2016 09:04 Go to next message
pere joseph rodríguez is currently offline pere joseph rodríguezFriend
Messages: 51
Registered: October 2014
Member
Hi,
I've got two main acceleo generators on the same plugin, packaged as a maven generator, but when running the generator from maven, the second generator does not detect the dynamically registered profiles.

Don't know if is a bug... on the second execution the profiles are already registered, so it don't get registered two times.

My code to register dynamic profiles:

private void registerProfile(ResourceSet resourceSet, URI uri) {
Resource profileResource = resourceSet.getResource(uri, true);
Profile profile=((Profile)EcoreUtil.getObjectByType(profileResource.getContents(),UMLPackage.Literals.PROFILE));
if(profile.getURI()!=null){

if(UMLPlugin.getEPackageNsURIToProfileLocationMap().get(profile.getURI().toString())==null){
UMLPlugin.getEPackageNsURIToProfileLocationMap().put(profile.getURI().toString(),URI.createURI((EcoreUtil.getURI(profile.getDefinition()).toString().replaceAll("\\\\","/")) ) );
}
if(resourceSet.getPackageRegistry().get(profile.getURI().toString())==null){
resourceSet.getPackageRegistry().put(profile.getURI().toString(),URI.createURI((EcoreUtil.getURI(profile.getDefinition()).toString().replaceAll("\\\\","/")) ) );
}


System.out.println("-- Registering profile "+profile.getURI().toString()+" ("+URI.createURI((EcoreUtil.getURI(profile.getDefinition()).toString().replaceAll("\\\\","/")) )+")");
}
}

My Maven generator launcher:

<plugin>
<groupId>org.eclipse.acceleo</groupId>
<artifactId>org.eclipse.acceleo.maven.launcher</artifactId>
<version>${acceleo.maven.launcher.version}</version>
<executions>
<execution>
<id>generate-jboss-ejb</id>
<phase>process-resources</phase>
<goals>
<goal>acceleo-launcher</goal>
</goals>
<configuration>
<generatorClass>org.eclipse.acceleo.module.test.main.GenerateJbossEjbXml</generatorClass>
<model>${generators.source.model}</model>
<outputFolder>${generators.target.folder}</outputFolder>
<failOnError>true</failOnError>
</configuration>
</execution>
<execution>
<id>generate-jboss-web</id>
<phase>process-resources</phase>
<goals>
<goal>acceleo-launcher</goal>
</goals>
<configuration>
<generatorClass>org.eclipse.acceleo.module.test.main.GenerateJbossWebXml</generatorClass>
<model>${generators.source.model}</model>
<outputFolder>${generators.target.folder}</outputFolder>
<failOnError>true</failOnError>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.test.mof2text</groupId>
<artifactId>org.eclipse.acceleo.module.test</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>


Thanks for anny suggestion.
Re: Dynamic profile not detected on second maven execution [message #1742859 is a reply to message #1742858] Thu, 08 September 2016 09:18 Go to previous messageGo to next message
pere joseph rodríguez is currently offline pere joseph rodríguezFriend
Messages: 51
Registered: October 2014
Member
Sorry,
doing changes I missed the correct registerProfiles code:

private void registerProfile(ResourceSet resourceSet, URI uri) {
Resource profileResource = resourceSet.getResource(uri, true);
Profile profile=((Profile)EcoreUtil.getObjectByType(profileResource.getContents(),UMLPackage.Literals.PROFILE));
if(profile.getURI()!=null){
if(EPackage.Registry.INSTANCE.get(profile.getURI().toString())==null){
EPackage.Registry.INSTANCE.put(profile.getURI().toString(),profile.getDefinition());
}
if(UMLPlugin.getEPackageNsURIToProfileLocationMap().get(profile.getURI().toString())==null){
UMLPlugin.getEPackageNsURIToProfileLocationMap().put(profile.getURI().toString(),URI.createURI((EcoreUtil.getURI(profile.getDefinition()).toString().replaceAll("\\\\","/")) ) );
}


System.out.println("-- Registering profile "+profile.getURI().toString()+" ("+URI.createURI((EcoreUtil.getURI(profile.getDefinition()).toString().replaceAll("\\\\","/")) )+")");
}
}
Re: Dynamic profile not detected on second maven execution [message #1743020 is a reply to message #1742859] Fri, 09 September 2016 14:00 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi,

You're using UML, so first things first are you using UMLResourcesUtil.init(resourceSet) on the resource set you use?

Other than that, are you sure you're using the same resource set for both generations? If not you will have to re-register your profile in the second one.

If none of these helps, please provide us with a way to reproduce the issue.

Laurent Goubet
Previous Topic:Unable to generate code
Next Topic:[Acceleo] Maven build for Acceleo 3.3
Goto Forum:
  


Current Time: Wed Sep 18 19:24:52 GMT 2024

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

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

Back to the top