1414import java .io .File ;
1515import java .io .FileInputStream ;
1616import java .util .List ;
17+ import java .util .Optional ;
1718import java .util .Set ;
1819import java .util .function .Consumer ;
1920import java .util .stream .Collectors ;
@@ -86,8 +87,11 @@ public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IPr
8687 this .runKantra (configuration );
8788 }
8889 }
90+
91+ private boolean invalidConfig = false ;
8992
9093 private void runKantra (ConfigurationElement configuration ) {
94+ this .invalidConfig = false ;
9195 if (WindupLaunchDelegate .activeRunner != null ) {
9296 WindupLaunchDelegate .activeRunner .kill ();
9397 }
@@ -127,6 +131,7 @@ protected IStatus run(IProgressMonitor monitor) {
127131 return Status .OK_STATUS ;
128132 }
129133 };
134+
130135 kantraJob .addJobChangeListener (new JobChangeAdapter () {
131136 @ Override
132137 public void done (IJobChangeEvent event ) {
@@ -150,10 +155,12 @@ public void done(IJobChangeEvent event) {
150155 if (WindupLaunchDelegate .activeRunner != null ) {
151156 WindupLaunchDelegate .activeRunner .kill ();
152157 }
153- org .jboss .tools .windup .model .domain .KantraRulesetParser .parseRulesetForKantraConfig (IssueExplorer .current .modelService .getKantraDelegate (configuration ));
154- IssueExplorer .current .modelService .save ();
155- IssueExplorer .current .markerService .generateMarkersForConfiguration (configuration );
156- IssueExplorer .current .viewService .renderReport (configuration );
158+ if (!WindupLaunchDelegate .this .invalidConfig ) {
159+ org .jboss .tools .windup .model .domain .KantraRulesetParser .parseRulesetForKantraConfig (IssueExplorer .current .modelService .getKantraDelegate (configuration ));
160+ IssueExplorer .current .modelService .save ();
161+ IssueExplorer .current .markerService .generateMarkersForConfiguration (configuration );
162+ IssueExplorer .current .viewService .renderReport (configuration );
163+ }
157164 }
158165 kantraMonitor .done ();
159166 }
@@ -172,6 +179,37 @@ public void done(IJobChangeEvent event) {
172179 String cli = WindupRuntimePlugin .computeWindupHome ();
173180
174181 File outputFile = new File (output );
182+
183+ Optional <Pair > overwriteOption = configuration .getOptions ().stream ().filter (option -> option .getKey ().equals ("overwrite" )).findFirst ();
184+ if (overwriteOption .isPresent ()) {
185+ Pair pair = overwriteOption .get ();
186+ if (!Boolean .valueOf (pair .getValue ())) {
187+ if (outputFile .exists ()) {
188+ Display .getDefault ().asyncExec (() -> {
189+ MessageDialog .openInformation (Display .getDefault ().getActiveShell (),
190+ Messages .launchErrorTitle , "Output location already exists. `--overwrite` option is required." );
191+ WindupUIPlugin .logErrorMessage ("Output location already exists. `--overwrite` option is required." ); //$NON-NLS-1$
192+ });
193+ this .invalidConfig = true ;
194+ kantraJob .cancel ();
195+ return ;
196+ }
197+ }
198+
199+ }
200+ else {
201+ if (outputFile .exists ()) {
202+ Display .getDefault ().asyncExec (() -> {
203+ MessageDialog .openInformation (Display .getDefault ().getActiveShell (),
204+ Messages .launchErrorTitle , "Output location already exists. `--overwrite` option is required." );
205+ WindupUIPlugin .logErrorMessage ("Output location already exists. `--overwrite` option is required." ); //$NON-NLS-1$
206+ });
207+ this .invalidConfig = true ;
208+ kantraJob .cancel ();
209+ return ;
210+ }
211+ }
212+
175213 if (!outputFile .exists ()) {
176214 try {
177215 outputFile .mkdirs ();
@@ -183,6 +221,8 @@ public void done(IJobChangeEvent event) {
183221 return ;
184222 }
185223 }
224+
225+
186226
187227 for (Pair pair : configuration .getOptions ()) {
188228 String name = pair .getKey ();
0 commit comments