Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Copyright Field in generated code from xtext(generated code)
Copyright Field in generated code from xtext [message #1747496] Tue, 15 November 2016 13:20 Go to next message
Mohammed Abed is currently offline Mohammed AbedFriend
Messages: 3
Registered: November 2016
Junior Member
Hallo Guys,

i want to add a unique copyright filed in the generated code from xtext.

As Example: when i generate code from xtext i have this scetion at the bottom of java file and xtend file:

/*
* generated by Xtext
*/

but i need to add my specific copyright filed as
/**
* Copyright @ Mohammed Abed
*/

please help me Smile
thank you
Re: Copyright Field in generated code from xtext [message #1747545 is a reply to message #1747496] Tue, 15 November 2016 19:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10434
Registered: July 2009
Senior Member
have a look at the workflow

			code = {
				encoding = "UTF-8"
				fileHeader = "/*\n * Here you go!!!\n */"
			}
Re: Copyright Field in generated code from xtext [message #1748126 is a reply to message #1747545] Fri, 18 November 2016 17:29 Go to previous messageGo to next message
Mohammed Abed is currently offline Mohammed AbedFriend
Messages: 3
Registered: November 2016
Junior Member
I have this code from .mwe2 file. but i don't know where shall i add this "Code" section

module org.scenariotools.sml.collaboration.Collaboration

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/scenariotools/sml/collaboration/Collaboration.xtext"
var fileExtensions = "collaboration"
var projectName = "org.scenariotools.sml.collaboration"
var runtimeProject = "../${projectName}"
var generateXtendStub = true

Workflow {
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."
registerGeneratedEPackage = "org.scenariotools.sml.SmlPackage"
registerGenModelFile = "platform:/resource/org.scenariotools.sml.model/model/sml.genmodel"

// Import ScenarioExpressions
registerGeneratedEPackage = "org.scenariotools.sml.expressions.scenarioExpressions.ScenarioExpressionsPackage"
registerGenModelFile = "platform:/resource/org.scenariotools.sml.expressions.model/model/ScenarioExpressions.genmodel"

// Import Ecore
registerGeneratedEPackage = "org.eclipse.emf.ecore.EcorePackage"
registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
}

component = DirectoryCleaner {
directory = "${runtimeProject}/src-gen"
}

component = DirectoryCleaner {
directory = "${runtimeProject}.ui/src-gen"
}

component = Generator {
pathRtProject = runtimeProject
pathUiProject = "${runtimeProject}.ui"
pathTestProject = "${runtimeProject}.tests"
projectNameRt = projectName
projectNameUi = "${projectName}.ui"
language = auto-inject {
uri = grammarURI

// Java API to access grammar elements (required by several other fragments)
fragment = grammarAccess.GrammarAccessFragment auto-inject {}

// generates Java API for the generated EPackages
// fragment = ecore.EcoreGeneratorFragment auto-inject {}

// the Ecore2Xtext specific terminal converter
fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment auto-inject {}

// serializer 2.0
fragment = serializer.SerializerFragment auto-inject {
//generateStub = false
}

// the old serialization component
// fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}

// a custom ResourceFactory for use with EMF
fragment = resourceFactory.ResourceFactoryFragment auto-inject {}

// the Antlr parser
fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
options = {
classSplitting = true
}
}

// Xtend-based API for validation
fragment = validation.ValidatorFragment auto-inject {
composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}

// old scoping and exporting API
// fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
// fragment = exporting.QualifiedNamesFragment auto-inject {}

// scoping and exporting API
fragment = scoping.ImportURIScopingFragment auto-inject {}
fragment = exporting.SimpleNamesFragment auto-inject {}
fragment = builder.BuilderIntegrationFragment auto-inject {}

// generator API
fragment = generator.GeneratorFragment auto-inject {}

// formatter API
// fragment = formatting.FormatterFragment auto-inject {}
fragment = ecore2xtext.FormatterFragment auto-inject {}

// labeling API
fragment = labeling.LabelProviderFragment auto-inject {}

// outline API
fragment = outline.OutlineTreeProviderFragment auto-inject {}
fragment = outline.QuickOutlineFragment auto-inject {}

// quickfix API
fragment = quickfix.QuickfixProviderFragment auto-inject {}

//content assist API
fragment = contentAssist.ContentAssistFragment auto-inject {}

// antlr parser generator tailored for content assist
fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {
options = {
classSplitting = true
}
}

// generates junit test support classes into Generator#pathTestProject
fragment = junit.Junit4Fragment auto-inject {}

// project wizard (optional)
// fragment = projectWizard.SimpleProjectWizardFragment auto-inject {
// generatorProjectName = "${projectName}.generator"
// }

// rename refactoring
fragment = refactoring.RefactorElementNameFragment auto-inject {}

// provides the necessary bindings for java types integration
// fragment = types.TypesGeneratorFragment auto-inject {}

// generates the required bindings only if the grammar inherits from Xbase
// fragment = xbase.XbaseGeneratorFragment auto-inject {}

// generates the required bindings only if the grammar inherits from Xtype
// fragment = xbase.XtypeGeneratorFragment auto-inject {}

// provides a preference page for template proposals
fragment = templates.CodetemplatesGeneratorFragment auto-inject {}

// provides a compare view
fragment = compare.CompareFragment auto-inject {}
}
}
}
Re: Copyright Field in generated code from xtext [message #1748129 is a reply to message #1748126] Fri, 18 November 2016 17:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10434
Registered: July 2009
Senior Member
do you still use an old 2.8.4 style workflow. is there a reason for that?
Re: Copyright Field in generated code from xtext [message #1748131 is a reply to message #1748129] Fri, 18 November 2016 18:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10434
Registered: July 2009
Senior Member
component = Generator {

fileHeader = "/*\n * GENERATED BY XTEXT\n */"
Re: Copyright Field in generated code from xtext [message #1748481 is a reply to message #1748131] Wed, 23 November 2016 13:58 Go to previous message
Mohammed Abed is currently offline Mohammed AbedFriend
Messages: 3
Registered: November 2016
Junior Member
thank you for your Helping Very Happy Very Happy
Previous Topic:Folding package/ file
Next Topic:Understanding the Web Services
Goto Forum:
  


Current Time: Sat Apr 29 21:36:31 GMT 2017

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

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