Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2019-04-11 09:29:30 +0000
committerNicolas FAUVERGUE2019-04-11 09:29:30 +0000
commita334b32027fd9de475acba83092452a520619bd8 (patch)
treed1b00cddabb8f91db7793ca228ce74f02225ecb2
parent081d2d417502fa32b229950a2b830c75a0080524 (diff)
downloadorg.eclipse.papyrus-a334b32027fd9de475acba83092452a520619bd8.tar.gz
org.eclipse.papyrus-a334b32027fd9de475acba83092452a520619bd8.tar.xz
org.eclipse.papyrus-a334b32027fd9de475acba83092452a520619bd8.zip
Bug 546239: [Toolsmiths][Validation] Plug-ins to validate profile
plug-in must be implemented - Implement the build.properties validation Change-Id: Ibc4f36d551c3f726f3761b846d650c4102348005 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementUtils.java19
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileBuildChecker.java76
-rw-r--r--plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginChecker.java3
3 files changed, 98 insertions, 0 deletions
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementUtils.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementUtils.java
index 5b2cc9dceb1..c9b22436cfd 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementUtils.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.common/src/org/eclipse/papyrus/toolsmiths/validation/common/utils/ProjectManagementUtils.java
@@ -63,6 +63,25 @@ public class ProjectManagementUtils {
}
/**
+ * This allows to get the build model of the project.
+ *
+ * @param project
+ * The current project.
+ * @return The build model representing the 'build.properties' file.
+ */
+ public static IBuildModel getPluginBuild(final IProject project) {
+ final IPluginModelBase pluginModelBase = ProjectManagementUtils.getPluginModelBase(project);
+ if (null != pluginModelBase) {
+ try {
+ return PluginRegistry.createBuildModel(pluginModelBase);
+ } catch (CoreException e) {
+ // Do nothing, just return null
+ }
+ }
+ return null;
+ }
+
+ /**
* This allows to check the file corresponding to the file name in parameter exists.
*
* @param container
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileBuildChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileBuildChecker.java
new file mode 100644
index 00000000000..b4d75717131
--- /dev/null
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfileBuildChecker.java
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * Copyright (c) 2019 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.toolsmiths.validation.profile.checkers;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.papyrus.toolsmiths.validation.common.utils.MarkersManagementUtils;
+import org.eclipse.papyrus.toolsmiths.validation.common.utils.ProjectManagementUtils;
+import org.eclipse.papyrus.toolsmiths.validation.profile.constants.ProfilePluginValidationConstants;
+import org.eclipse.pde.core.build.IBuild;
+import org.eclipse.pde.core.build.IBuildEntry;
+import org.eclipse.pde.core.build.IBuildModel;
+
+/**
+ * This class allows to check the 'build.properties' needed for the profile file.
+ */
+public class ProfileBuildChecker {
+
+ /**
+ * This allows to check the build of the profile file.
+ *
+ * @param project
+ * The current project to check.
+ * @param profileFile
+ * The profile for which one to check.
+ */
+ public static void checkBuildFile(final IProject project, final IFile profileFile) {
+
+ // Get the build.properties entries from the project
+ final IBuildModel buildModel = ProjectManagementUtils.getPluginBuild(project);
+ if (null != buildModel) {
+
+ // Create the conditions:
+ // - Boolean to determinate if the build contains folder containing the profile
+ boolean containsProfile = false;
+
+ // Calculate the profile path
+ final String profilePath = profileFile.getProjectRelativePath().toString();
+
+ final IBuild build = buildModel.getBuild();
+ final IBuildEntry buildEntry = build.getEntry(IBuildEntry.BIN_INCLUDES);
+
+ // Iterate on existing tokens
+ final String[] tokens = buildEntry.getTokens();
+ for (int i = 0; i < tokens.length && !containsProfile; i++) {
+ containsProfile = profilePath.startsWith(tokens[i]);
+ }
+
+ // Create marker for UMLProfile extension point if needed
+ if (!containsProfile) {
+ final IFile buildPropertiesFile = ProjectManagementUtils.getBuildFile(project);
+
+ MarkersManagementUtils.createMarker(
+ buildPropertiesFile,
+ ProfilePluginValidationConstants.PROFILE_PLUGIN_VALIDATION_TYPE,
+ "The build does not contains entry for file '" + profilePath + "'", //$NON-NLS-1$ //$NON-NLS-2$
+ IMarker.SEVERITY_ERROR);
+ }
+ }
+ }
+
+}
diff --git a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginChecker.java b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginChecker.java
index 9a82300433a..e3d1f40a69e 100644
--- a/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginChecker.java
+++ b/plugins/toolsmiths/validation/org.eclipse.papyrus.toolsmiths.validation.profile/src/org/eclipse/papyrus/toolsmiths/validation/profile/checkers/ProfilePluginChecker.java
@@ -60,6 +60,9 @@ public class ProfilePluginChecker {
if (!profiles.isEmpty()) {
ProfileExtensionsChecker.checkPluginXMLFile(project, profileFile, profiles);
}
+
+ // Check the build for file
+ ProfileBuildChecker.checkBuildFile(project, profileFile);
}
}

Back to the top