--- /dev/null
+/*
+ * Common
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Daeryong Park <bdragon.park@samsung.com>
+ * Hyeongseok Heo <harry.heo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd.
+ *
+ */
+package org.tizen.rt.product.meta;
+
+/**
+ * @since 2017. 6. 8.
+ * @author Daeryong Park {@literal <bdragon.park@samsung.com>}
+ */
+public interface IModelConstants {
+
+ public String FILE_NAME_BUILD_META_XML = "buildSpec.xml"; //$NON-NLS-1$
+ public String FILE_NAME_FLASH_META_XML = "flashSpec.xml"; //$NON-NLS-1$
+ public String FILE_NAME_DEBUG_META_XML = "debugSpec.xml"; //$NON-NLS-1$
+
+ public String FILE_NAME_BUILD_META_XSD = "buildSpec.xsd"; //$NON-NLS-1$
+ public String FILE_NAME_FLASH_META_XSD = "flashSpec.xsd"; //$NON-NLS-1$
+ public String FILE_NAME_DEBUG_META_XSD = "debugSpec.xsd"; //$NON-NLS-1$
+
+}
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
+import org.tizen.rt.product.meta.IModelConstants;
import org.tizen.rt.product.meta.RtMetaPlugin;
import org.tizen.rt.product.meta.model.build.Build;
import org.tizen.rt.product.meta.model.debug.Debugs;
private MetaModelUtil() {
}
+ /**
+ * Copy default buildSpec.xml file to destination and load copied buildSpec.xml file
+ * @param destination File full path string
+ * @return Load {@link Build} model instance
+ * @throws IOException
+ * @throws JAXBException
+ */
+ public static Build copyDefaultBuildModelAndLoad(String destination) throws IOException, JAXBException {
+ InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_BUILD_META_XML);
+ return copyDefaultModelAndLoad(Build.class, source, destination);
+ }
+
+ /**
+ * Copy default flashSpec.xml file to destination and load copied flashSpec.xml file
+ * @param destination File full path string
+ * @return Load {@link Flash} model instance
+ * @throws IOException
+ * @throws JAXBException
+ */
+ public static Flash copyDefaultFlashModelAndLoad(String destination) throws IOException, JAXBException {
+ InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_FLASH_META_XML);
+ return copyDefaultModelAndLoad(Flash.class, source, destination);
+ }
+
+ /**
+ * Copy default debusSpec.xml file to destination and load copied debugSpec.xml file
+ * @param destination File full path string
+ * @return Load {@link Debugs} model instance
+ * @throws IOException
+ * @throws JAXBException
+ */
+ public static Debugs copyDefaultDebugModelAndLoad(String destination) throws IOException, JAXBException {
+ InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_DEBUG_META_XML);
+ return copyDefaultModelAndLoad(Debugs.class, source, destination);
+ }
+
+ private static <T> T copyDefaultModelAndLoad(Class<T> clazz, InputStream source, String destination) throws JAXBException, IOException {
+ Path destPath = Paths.get(destination);
+ Files.copy(source, destPath, StandardCopyOption.REPLACE_EXISTING);
+ File destFile = new File(destination);
+ return loadModel(clazz, destFile);
+ }
+
@SuppressWarnings("unchecked")
private static <T> T loadModel(Class<T> clazz, File modelXmlFile) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(clazz);
*/
package org.tizen.rt.product.meta.model;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.junit.Assert;
import org.junit.Test;
+import org.tizen.rt.product.meta.IModelConstants;
import org.tizen.rt.product.meta.RtMetaPlugin;
import org.tizen.rt.product.meta.model.build.Build;
import org.tizen.rt.product.meta.model.debug.Debugs;
MetaModelUtil.validateDebugFile(xmlFileStream);
}
+ @Test
+ public void copyAndLoadBuildModelTest() throws IOException, JAXBException {
+ String fileName = IModelConstants.FILE_NAME_BUILD_META_XML;
+ MetaModelUtil.copyDefaultBuildModelAndLoad(fileName);
+ File file = new File(fileName);
+ file.delete();
+ }
+
+ @Test
+ public void copyAndLoadFlashModelTest() throws IOException, JAXBException {
+ String fileName = IModelConstants.FILE_NAME_FLASH_META_XML;
+ MetaModelUtil.copyDefaultBuildModelAndLoad(fileName);
+ File file = new File(fileName);
+ file.delete();
+ }
+
+ @Test
+ public void copyAndLoadDebugModelTest() throws IOException, JAXBException {
+ String fileName = IModelConstants.FILE_NAME_DEBUG_META_XML;
+ MetaModelUtil.copyDefaultBuildModelAndLoad(fileName);
+ File file = new File(fileName);
+ file.delete();
+ }
+
}
public static String RtosFlashWizard_WindowTitle;
public static String FlashHandler_NotFoundBuildInfo;
+ public static String FlashHandler_BuildInfoIsNotNormal;
public static String LaunchShortcut_NotFoundBuildInfo;
public static String RtosBuildDialogPage_lblNewLabel_text;
#Wed Mar 29 14:25:05 KST 2017
RtGitImportWizard_WindowTitle=New TizenRT Project from Git
FlashHandler_NotFoundBuildInfo=Flash execution failed. Please build it first.
+FlashHandler_BuildInfoIsNotNormal=Flash execution failed. Please check the build was done normally.
LaunchShortcut_NotFoundBuildInfo=Debug execution failed. Please build it first.
NewArtikProjectWizard_CreateOperationLabel=Create new TizenRT project
*/
package org.tizen.rt.ide.meta;
+import org.tizen.rt.product.meta.IModelConstants;
+
/**
* @since 2017. 5. 25.
* @author Daeryong Park {@literal <bdragon.park@samsung.com>}
*/
-public interface IMetaConstants {
+public interface IMetaConstants extends IModelConstants {
public String FILE_NAME_BUILD_INFO = "build.info"; //$NON-NLS-1$
public String PATH_BUILD_OUTPUT = "build/output"; //$NON-NLS-1$
public String PROP_NAME_OPTION = "option"; //$NON-NLS-1$
public String PROP_COMMENT_BUILD_INFO = "Tizen RT build information"; //$NON-NLS-1$
- public String FILE_NAME_BUILD_META_XML = "buildSpec.xml"; //$NON-NLS-1$
- public String FILE_NAME_FLASH_META_XML = "flashSpec.xml"; //$NON-NLS-1$
- public String FILE_NAME_DEBUG_META_XML = "debugSpec.xml"; //$NON-NLS-1$
-
- public String FILE_NAME_BUILD_META_XSD = "buildSpec.xsd"; //$NON-NLS-1$
- public String FILE_NAME_FLASH_META_XSD = "flashSpec.xsd"; //$NON-NLS-1$
- public String FILE_NAME_DEBUG_META_XSD = "debugSpec.xsd"; //$NON-NLS-1$
-
}
}
}
- private static File getMetaFile(IProject project, String board, String metaFileName) throws MetaNotFoundException {
+ private static String getMetaFilePath(IProject project, String board, String metaFileName) {
String configPath = project.getLocation().toString() + File.separator + PATH_BUILD_CONFIGS;
- File metaFile = new File(configPath, board + File.separator + metaFileName);
+ String metaFilePath = configPath + File.separator + board + File.separator + metaFileName;
+ return metaFilePath;
+ }
+
+ private static File getMetaFile(IProject project, String board, String metaFileName) throws MetaNotFoundException {
+ String metaFilePath = getMetaFilePath(project, board, metaFileName);
+ File metaFile = new File(metaFilePath);
if (metaFile == null || !metaFile.exists()) {
throw new MetaNotFoundException(metaFileName + " file not exist : " + metaFile.toString()); //$NON-NLS-1$
}