Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1509 Ignore extractTemplatesWithOldCinfiguration #1536

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removed exception that was used to differenciate between test and pro…
…duction and added an argument instead.
LarsReinken committed May 24, 2022
commit f947e502428228ed6ad406ae3f1d046de38db22d
Original file line number Diff line number Diff line change
@@ -50,8 +50,9 @@ public void initAdaptTemplatesTest() throws URISyntaxException, IOException {
@Test
public void adaptTemplatesTest() throws Exception {

String args[] = new String[1];
String args[] = new String[2];
args[0] = "adapt-templates";
args[1] = "--all";

execute(args, false);

Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import com.devonfw.cobigen.impl.adapter.TemplateAdapterImpl;

import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

/**
* This class handles the user defined template directory e.g. determining and obtaining the latest templates jar,
@@ -30,6 +31,12 @@ public class AdaptTemplatesCommand extends CommandCommons {
*/
private static Logger LOG = LoggerFactory.getLogger(CobiGenCLI.class);

/**
* If this options is enabled, all templates are unpacked.
mdukhan marked this conversation as resolved.
Show resolved Hide resolved
*/
@Option(names = { "--all" }, negatable = true, description = MessagesConstants.UPDATE_ALL_DESCRIPTION)
mdukhan marked this conversation as resolved.
Show resolved Hide resolved
boolean adaptAll;

@Override
public Integer doAction() throws Exception {

@@ -74,9 +81,13 @@ private List<Path> getJarsToAdapt(TemplateAdapter templateAdapter, List<Path> te
printJarsForSelection(templateAdapter, templateJars);

List<String> userSelection = new ArrayList<>();
for (String templateSelection : ValidationUtils.getUserInput().split(",")) {
userSelection.add(templateSelection);
}

if (this.adaptAll)
mdukhan marked this conversation as resolved.
Show resolved Hide resolved
userSelection.add("0");
else
for (String templateSelection : ValidationUtils.getUserInput().split(",")) {
userSelection.add(templateSelection);
}

if (userSelection.contains("0")) {
jarsToAdapt = templateJars;
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

import org.slf4j.Logger;
@@ -131,14 +130,7 @@ public static void throwNoTriggersMatched(Path inputFile, boolean isJavaInput, b
public static String getUserInput() {

String userInput = "";
try {
userInput = inputReader.nextLine();
mdukhan marked this conversation as resolved.
Show resolved Hide resolved
} catch (NoSuchElementException e) {
// This Case is for the Adapt-templates Command to cover the next line in Test adaptTemplatesTest when no
// UserInput can be scanned
LOG.info("No User Input, By default All found templates will be adapted");
userInput = "0";
}
return userInput;
}