From fba4f2e5a1dd538928501ec8ee7796aa62836dfd Mon Sep 17 00:00:00 2001 From: Adam Knapp Date: Thu, 8 Jul 2021 16:25:28 +0200 Subject: [PATCH] Improving CLI applications Signed-off-by: Adam Knapp --- .../eclipse/titan/designer/application/ImportProject.java | 6 ++++-- .../org/eclipse/titan/designer/application/InvokeBuild.java | 6 +++--- .../eclipse/titan/designer/core/ant/AntScriptGenerator.java | 6 ++++++ .../eclipse/titan/designer/wizards/TITANProjectOpener.java | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/ImportProject.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/ImportProject.java index efc4f135e..c2f96556f 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/ImportProject.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/ImportProject.java @@ -57,8 +57,10 @@ public final class ImportProject implements IApplication { } try { final IProject project = TITANProjectOpener.open(projectPath); - if (!TITANProjectOpener.check(project)) { - System.out.println("The project with name `" + project.getName() + "' is imported, but it is not a Titan project."); + if (TITANProjectOpener.check(project)) { + System.out.println("The project with name `" + project.getName() + "' is imported in the workspace!"); + } else { + System.out.println("The project with name `" + project.getName() + "' is imported in the workspace, but it is not a Titan project."); } } catch (Exception e) { ErrorReporter.logExceptionStackTrace("Error while imporing project with name `" diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/InvokeBuild.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/InvokeBuild.java index f844f0f97..3890e102c 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/InvokeBuild.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/application/InvokeBuild.java @@ -55,13 +55,13 @@ public final class InvokeBuild implements IApplication { MakefileCreationData.DEFAULT_JAVA_TARGET_PROPERTY), MakefileCreationData.DefaultJavaTarget.EXECUTABLE.toString()); project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.GENERATE_START_SH_SCRIPT_PROPERTY), String.valueOf(true)); - if (AntScriptGenerator.generateAndStoreBuildXML(project, true)) { + if (AntScriptGenerator.generateAndStoreBuildXML(project, false)) { AntLaunchConfigGenerator.createAntLaunchConfiguration(project); AntLaunchConfigGenerator.addAntBuilder(project); + AntLaunchConfigGenerator.setAntBuilderEnabled(project, true); + CliScriptGenerator.generateAndStoreScripts(project); project.refreshLocal(IResource.DEPTH_ONE, null); } - CliScriptGenerator.generateAndStoreScripts(project); - AntLaunchConfigGenerator.setAntBuilderEnabled(project, true); } private Integer closeWorkspace() { diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/AntScriptGenerator.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/AntScriptGenerator.java index 31f988ed0..b0d0819ea 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/AntScriptGenerator.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/core/ant/AntScriptGenerator.java @@ -242,6 +242,12 @@ public final class AntScriptGenerator { return null; } final SourceInfo[] sourceInfos = convert(getClasspath(config)); + if (sourceInfos == null || sourceInfos.length == 0) { + ErrorReporter.parallelErrorDisplayInMessageDialog( + "Error while generating the ANT script 'jarbuild.xml' for project", + "Error while resolving classpaths!"); + return null; + } JavaAppLaunchConfigGenerator.deleteTemporaryJavaAppLaunchConfiguration(project); DocumentBuilder docBuilder = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/wizards/TITANProjectOpener.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/wizards/TITANProjectOpener.java index 34f27cbea..7e8f0671f 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/wizards/TITANProjectOpener.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/wizards/TITANProjectOpener.java @@ -52,7 +52,7 @@ public final class TITANProjectOpener { * @return If a project with the same name already exists in the workspace then the handler of this project * is returned, otherwise the project on the specified path is created in the workspace. * {@code null} is returned upon empty or null path - * @throws CoreException + * @throws CoreException, FileNotFoundException */ public static IProject open(final IPath path) throws CoreException, FileNotFoundException { if (path == null || path.isEmpty()) { @@ -93,7 +93,7 @@ public final class TITANProjectOpener { * @return If a project with the same name already exists in the workspace then the handler of this project * is returned, otherwise the project on the specified path is created in the workspace. * {@code null} is returned upon empty or null path - * @throws CoreException + * @throws CoreException, FileNotFoundException */ public static IProject open(final String pathString) throws CoreException, FileNotFoundException { return open(new Path(pathString)); -- GitLab