aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozsef Makai2014-05-17 12:47:03 (EDT)
committerJozsef Makai2014-05-17 12:47:03 (EDT)
commitdb4160141ac38935d10f066ca0f768c52dcea714 (patch)
tree162c303845943204ca163cb4516e4eb6dbdc09c3
parentd35bce30f60c55eda17d15af0b74a1b66176035d (diff)
downloadorg.eclipse.incquery-db4160141ac38935d10f066ca0f768c52dcea714.zip
org.eclipse.incquery-db4160141ac38935d10f066ca0f768c52dcea714.tar.gz
org.eclipse.incquery-db4160141ac38935d10f066ca0f768c52dcea714.tar.bz2
[398797] Updated the interface of the Maven builder pluginrefs/changes/75/26775/1
Change-Id: Idfa5d6a47b62343e6a361b7e29433f2a051dd12d Signed-off-by: Jozsef Makai <reyuulol@gmail.com>
-rw-r--r--maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/IncqueryBuilderMojo.java56
-rw-r--r--maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/helper/Metamodel.java (renamed from maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/helper/ModelPair.java)12
2 files changed, 30 insertions, 38 deletions
diff --git a/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/IncqueryBuilderMojo.java b/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/IncqueryBuilderMojo.java
index a3d25d1..1409651 100644
--- a/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/IncqueryBuilderMojo.java
+++ b/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/IncqueryBuilderMojo.java
@@ -22,9 +22,10 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
-import org.eclipse.incquery.maven.incquerybuilder.helper.ModelPair;
+import org.eclipse.incquery.maven.incquerybuilder.helper.Metamodel;
import org.eclipse.incquery.maven.incquerybuilder.setup.EMFPatternLanguageMavenStandaloneSetup;
import org.eclipse.incquery.maven.incquerybuilder.setup.MavenBuilderGenmodelLoader;
import org.eclipse.xtext.maven.Language;
@@ -39,19 +40,12 @@ import org.eclipse.xtext.maven.XtextGenerator;
* @requiresDependencyResolution compile
*/
public class IncqueryBuilderMojo extends AbstractMojo {
- /**
- * FQN-s of the EPackage classes
- *
- * @parameter
- * @required
- */
- private List<String> ePackages;
/**
* @parameter
* @required
*/
- private List<ModelPair> modelPairs;
+ private List<Metamodel> metamodels;
/**
* the project relative path to the output directory
@@ -121,9 +115,7 @@ public class IncqueryBuilderMojo extends AbstractMojo {
registerGenmodelExtension();
- resolveEPackages();
-
- registerModelPairs();
+ registerMetamodels();
XtextGenerator generator = new XtextGenerator();
@@ -209,29 +201,20 @@ public class IncqueryBuilderMojo extends AbstractMojo {
}
/**
- * Register user given metamodel NSURI and genmodel URI pairs
- */
- private void registerModelPairs() {
- for (ModelPair modelPair : modelPairs) {
- String genmodelUri = modelPair.getGenmodelUri();
- if (URI.createURI(genmodelUri).isRelative()) {
- genmodelUri = project.getBasedir().getAbsolutePath() + File.separator + genmodelUri;
- }
- MavenBuilderGenmodelLoader.addGenmodel(modelPair.getModelNsUri(), "file://" + genmodelUri);
- }
- }
-
- /**
- * To access the eINSTANCE field of the user given EPackage classes
- *
- * @throws MojoExecutionException
+ * Register user given metamodel NSURI (determining from the EPackage) and genmodel URI pairs
+ * @throws MojoExecutionException
*/
- private void resolveEPackages() throws MojoExecutionException {
- for (String fqnOfEPackageClass : ePackages) {
+ private void registerMetamodels() throws MojoExecutionException {
+ for (Metamodel metamodel : metamodels)
+ {
+ String fqnOfEPackageClass = null;
+ String metamodelNSURI = null;
try {
+ fqnOfEPackageClass = metamodel.getPackageClass();
+
Class<?> ePackageClass = Class.forName(fqnOfEPackageClass);
-
+
Field instanceField = ePackageClass.getDeclaredField("eINSTANCE");
Class<?> instanceFieldType = instanceField.getType();
@@ -243,7 +226,8 @@ public class IncqueryBuilderMojo extends AbstractMojo {
throw new MojoExecutionException("Execution failed due to wrong type of eINSTANCE");
}
- instanceField.get(null);
+ EPackage ePackage = (EPackage)instanceField.get(null);
+ metamodelNSURI = ePackage.getNsURI();
} catch (ClassNotFoundException e) {
getLog().error("Couldn't find class " + fqnOfEPackageClass + " on the classpath.");
@@ -257,9 +241,17 @@ public class IncqueryBuilderMojo extends AbstractMojo {
} catch (IllegalAccessException e) {
}
+
+ String genmodelUri = metamodel.getGenmodelUri();
+ if (URI.createURI(genmodelUri).isRelative()) {
+ genmodelUri = project.getBasedir().getAbsolutePath() + File.separator + genmodelUri;
+ }
+
+ MavenBuilderGenmodelLoader.addGenmodel(metamodelNSURI, "file://" + genmodelUri);
}
}
+
/**
* To register genmodel extension and according factory to the extension factory
*/
diff --git a/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/helper/ModelPair.java b/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/helper/Metamodel.java
index 08af597..18cfeff 100644
--- a/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/helper/ModelPair.java
+++ b/maven/incquery-maven-plugin/src/main/java/org/eclipse/incquery/maven/incquerybuilder/helper/Metamodel.java
@@ -11,13 +11,13 @@
package org.eclipse.incquery.maven.incquerybuilder.helper;
-public class ModelPair {
+public class Metamodel {
/**
* @property
* @required
*/
- private String modelNsUri;
+ private String packageClass;
/**
* @property
@@ -25,12 +25,12 @@ public class ModelPair {
*/
private String genmodelUri;
- public String getModelNsUri() {
- return modelNsUri;
+ public String getPackageClass() {
+ return packageClass;
}
- public void setModelNsUri(String modelNsUri) {
- this.modelNsUri = modelNsUri;
+ public void setPackageClass(String packageClass) {
+ this.packageClass = packageClass;
}
public String getGenmodelUri() {