Java Code Examples for io.fabric8.utils.Strings

The following examples show how to use io.fabric8.utils.Strings. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: updatebot   Source File: PullRequestCommentReadWriteTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSingleUpdate() throws Exception {
    String dependency = "cheese";
    String version = "1.2.3";

    PushVersionChanges command = new PushVersionChanges(NPM, dependency, version);
    parentContext.updateVersion(NPM, dependency, version);
    assertContextCommandComment(command,
            COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency, version));


    String comment = command.createPullRequestComment();
    CompositeCommand parsedCommands = parseCommandComment(comment, 1);
    PushVersionChanges parsedUpdateVersion = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
    CommandAssertions.assertPushVersionContext(parsedUpdateVersion, NPM, dependency, version);
}
 
Example 2
Source Project: updatebot   Source File: PullRequestCommentReadWriteTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoUpdates() throws Exception {
    String dependency1 = "beer";
    String version1 = "2.3.4";

    String dependency2 = "wine";
    String version2 = "4.5.6";

    PushVersionChanges command = new PushVersionChanges(NPM, dependency1, version1, dependency2, version2);

    assertContextCommandComment(command,
            COMMAND_COMMENT_INDENT + Strings.join(" ", PUSH_VERSION, "--kind", NPM, dependency1, version1, dependency2, version2));

    String comment = command.createPullRequestComment();
    CompositeCommand parsedCommands = parseCommandComment(comment, 1);
    PushVersionChanges parsedUpdateVersion1 = CommandAssertions.assertChildIsPushVersionChanges(parsedCommands, 0);
    CommandAssertions.assertPushVersionContext(parsedUpdateVersion1, NPM, dependency1, version1, dependency2, version2);
}
 
Example 3
Source Project: updatebot   Source File: PomHelperTest.java    License: Apache License 2.0 6 votes vote down vote up
protected static void assertPluginVersionChanged(File file, Document doc, DependencyVersionChange change) {
    boolean found = false;
    List<Element> elements = findElementsWithName(doc.getRootElement(), "plugin");
    for (Element element : elements) {
        String groupId = firstChildTextContent(element, "groupId");
        String artifactId = firstChildTextContent(element, "artifactId");
        String version = firstChildTextContent(element, "version");
        if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
            if (change.matches(groupId, artifactId)) {
                found = true;
                if (!version.startsWith("$")) {
                    LOG.info("File " + file + " has plugin " + change.getDependency() + " version: " + version);
                    assertThat(version).describedAs("File " + file + " plugin version for " + change.getDependency()).isEqualTo(change.getVersion());
                }
            }
        }
    }
    assertThat(found).describedAs("File " + file + " does not have plugin " +
            change.getDependency() + " version: " + change.getVersion()).isTrue();
}
 
Example 4
Source Project: updatebot   Source File: PomHelperTest.java    License: Apache License 2.0 6 votes vote down vote up
protected static void assertDependencyVersionChanged(File file, Document doc, DependencyVersionChange change) {
        boolean found = false;
        List<Element> elements = findElementsWithName(doc.getRootElement(), "dependency");
        for (Element element : elements) {
            String groupId = firstChildTextContent(element, "groupId");
            String artifactId = firstChildTextContent(element, "artifactId");
            String version = firstChildTextContent(element, "version");
            if (Strings.notEmpty(groupId) && Strings.notEmpty(artifactId) && Strings.notEmpty(version)) {
                if (change.matches(groupId, artifactId)) {
                    found = true;
                    if (!version.startsWith("$")) {
                        LOG.info("File " + file + " has dependency " + change.getDependency() + " version: " + version);
                        assertThat(version).describedAs("File " + file + " dependency version for " + change.getDependency()).isEqualTo(change.getVersion());
                    }
                }
            }
        }
/*
        assertThat(found).describedAs("File " + file + " does not have dependency " +
                change.getDependency() + " version: " + change.getVersion()).isTrue();
*/
    }
 
Example 5
Source Project: fabric8-forge   Source File: PopulateMavenRepositoryTest.java    License: Apache License 2.0 6 votes vote down vote up
protected List<String> getArchetypesFromJar(File archetypeJar) throws IOException {
    assertThat(archetypeJar).exists();
    JarFile jar = new JarFile(archetypeJar);
    String entryName = "archetype-catalog.xml";
    ZipEntry entry = jar.getEntry(entryName);
    assertThat(entry).describedAs("Missing entry " + entryName + " in jar " + archetypeJar).isNotNull();

    SortedSet<String> artifactIds = new TreeSet<>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(jar.getInputStream(entry));
        Document doc = builder.parse(is);
        NodeList artifactTags = doc.getElementsByTagName("artifactId");
        for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
            Node element = artifactTags.item(i);
            String artifactId = element.getTextContent();
            if (Strings.isNotBlank(artifactId)) {
                artifactIds.add(artifactId);
            }
        }
    } catch (Exception e) {
        fail("Failed to parse " + entryName + " in jar " + archetypeJar + ". Exception " + e, e);
    }
    return new ArrayList<>(artifactIds);
}
 
Example 6
Source Project: fabric8-forge   Source File: CreateQuickstartProjectKT.java    License: Apache License 2.0 6 votes vote down vote up
protected List<String> getArchetypesFromJar() throws IOException {
    String entryName = "archetype-catalog.xml";
    URL url = getClass().getClassLoader().getResource(entryName);
    assertThat(url).describedAs("Could not find resource " + entryName + " on the classpath!").isNotNull();

    SortedSet<String> artifactIds = new TreeSet<>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(url.openStream());
        Document doc = builder.parse(is);
        NodeList artifactTags = doc.getElementsByTagName("artifactId");
        for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
            Node element = artifactTags.item(i);
            String artifactId = element.getTextContent();
            if (Strings.isNotBlank(artifactId)) {
                artifactIds.add(artifactId);
            }
        }
    } catch (Exception e) {
        fail("Failed to parse " + entryName + " in catalog " + url + ". Exception " + e, e);
    }
    return new ArrayList<>(artifactIds);
}
 
Example 7
Source Project: fabric8-forge   Source File: UICommands.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * A name of the form "foo-bar-whatnot" is turned into "Foo: Bar Whatnot"
 */
public static String unshellifyName(String name) {
    if (Strings.isNotBlank(name)) {
        if (name.indexOf('-') >= 0 && name.toLowerCase().equals(name)) {
            String[] split = name.split("-");
            StringBuffer buffer = new StringBuffer();
            int idx = 0;
            for (String part : split) {
                if (idx == 1) {
                    buffer.append(": ");
                } else if (idx > 1) {
                    buffer.append(" ");
                }
                buffer.append(capitalize(part));
                idx++;
            }
            return buffer.toString();
        }
    }
    return name;
}
 
Example 8
Source Project: fabric8-forge   Source File: UICommands.java    License: Apache License 2.0 6 votes vote down vote up
protected static String getResultMessage(Result result) {
    if (result instanceof CompositeResult) {
        CompositeResult compositeResult = (CompositeResult) result;
        List<Result> results = compositeResult.getResults();
        StringBuilder buffer = new StringBuilder();
        for (Result childResult : results) {
            String childResultMessage = getResultMessage(childResult);
            if (Strings.isNotBlank(childResultMessage)) {
                if (buffer.length() > 0) {
                    buffer.append("\n");
                }
                buffer.append(childResultMessage);
            }
        }
        return buffer.toString();
    } else if (result != null) {
        return result.getMessage();
    } else {
        return null;
    }
}
 
Example 9
Source Project: fabric8-forge   Source File: RepositoryResource.java    License: Apache License 2.0 6 votes vote down vote up
public CommitInfo createCommitInfo(RevCommit entry) {
    final Date date = GitUtils.getCommitDate(entry);
    PersonIdent authorIdent = entry.getAuthorIdent();
    String author = null;
    String name = null;
    String email = null;
    String avatarUrl = null;
    if (authorIdent != null) {
        author = authorIdent.getName();
        name = authorIdent.getName();
        email = authorIdent.getEmailAddress();

        // lets try default the avatar
        if (Strings.isNotBlank(email)) {
            avatarUrl = getAvatarUrl(email);
        }
    }
    boolean merge = entry.getParentCount() > 1;
    String shortMessage = entry.getShortMessage();
    String sha = entry.getName();
    return new CommitInfo(sha, author, name, email, avatarUrl, date, merge, shortMessage);
}
 
Example 10
Source Project: fabric8-forge   Source File: RepositoryResource.java    License: Apache License 2.0 6 votes vote down vote up
protected void configureBranch(Git git, String branch) {
    // lets update the merge config
    if (Strings.isNotBlank(branch)) {
        StoredConfig config = git.getRepository().getConfig();
        if (Strings.isNullOrBlank(config.getString("branch", branch, "remote")) || Strings.isNullOrBlank(config.getString("branch", branch, "merge"))) {
            config.setString("branch", branch, "remote", getRemote());
            config.setString("branch", branch, "merge", "refs/heads/" + branch);
            try {
                config.save();
            } catch (IOException e) {
                LOG.error("Failed to save the git configuration to " + basedir
                        + " with branch " + branch + " on remote repo: " + remoteRepository + " due: " + e.getMessage() + ". This exception is ignored.", e);
            }
        }
    }
}
 
Example 11
Source Project: fabric8-forge   Source File: ProjectFileSystem.java    License: Apache License 2.0 6 votes vote down vote up
public void asyncCloneOrPullJenkinsWorkflows(final UserDetails userDetails) {
    final File folder = getJenkinsfilesLibraryFolder();
    if (Strings.isNotBlank(jenkinsfileLibraryGitUrl)) {
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                StopWatch watch = new StopWatch();
                try {
                    LOG.debug("Cloning or pulling jenkins workflow repo from " + jenkinsfileLibraryGitUrl + " to " + folder);
                    UserDetails anonymous = userDetails.createAnonymousDetails();
                    cloneOrPullRepo(anonymous, folder, jenkinsfileLibraryGitUrl, null, null);
                } catch (Exception e) {
                    LOG.error("Failed to clone jenkins workflow repo from : " + jenkinsfileLibraryGitUrl + ". " + e, e);
                } finally {
                    LOG.info("asyncCloneOrPullJenkinsWorkflows took " + watch.taken());
                }
            }
        });
    } else {
        LOG.warn("Cannot clone jenkins workflow repository as the environment variable JENKINSFILE_LIBRARY_GIT_REPOSITORY is not defined");
    }
}
 
Example 12
Source Project: fabric8-forge   Source File: BuildConfigs.java    License: Apache License 2.0 6 votes vote down vote up
public static BuildConfig createBuildConfig(String buildConfigName, Map<String, String> labels, String gitUrlText, String outputImageStreamName, String imageText, String webhookSecret) {
    BuildConfigBuilder buildConfigBuilder = buildConfigBuilder(buildConfigName, labels);
    BuildConfigSpecBuilder specBuilder = new BuildConfigSpecBuilder();

    addBuildParameterGitSource(specBuilder, gitUrlText);
    if (Strings.isNotBlank(outputImageStreamName)) {
        addBuildParameterOutput(specBuilder, outputImageStreamName);
    }
    if (Strings.isNotBlank(imageText)) {
        addBuildConfigSpectiStrategy(specBuilder, imageText);
    }
    if (Strings.isNotBlank(webhookSecret)) {
        addWebHookTriggers(specBuilder, webhookSecret);
    }
    return buildConfigBuilder.withSpec(specBuilder.build()).build();
}
 
Example 13
Source Project: fabric8-forge   Source File: ServicesList.java    License: Apache License 2.0 6 votes vote down vote up
private void printServices(ServiceList services, PrintStream out) {
    TablePrinter table = new TablePrinter();
    table.columns("id", "labels", "selector", "port");
    List<Service> items = services.getItems();
    if (items == null) {
        items = Collections.EMPTY_LIST;
    }
    Filter<Service> filter = KubernetesHelper.createServiceFilter(filterText.getValue());
    for (Service service : items) {
        if (filter.matches(service)) {
            String labels = KubernetesHelper.toLabelsString(service.getMetadata().getLabels());
            String selector = KubernetesHelper.toLabelsString(getSelector(service));
            Set<Integer> ports = getPorts(service);
            List<Integer> portList = new ArrayList<>(ports);
            String portText;
            if (portList.size() == 1) {
                portText = portList.get(0).toString();

            } else {
                portText = Strings.join(portList, ", ");
            }
            table.row(KubernetesHelper.getName(service), labels, selector, portText);
        }
    }
    table.print();
}
 
Example 14
Source Project: fabric8-forge   Source File: CommandHelpers.java    License: Apache License 2.0 6 votes vote down vote up
public static String getResultMessage(Result result) {
    if (result instanceof CompositeResult) {
        CompositeResult compositeResult = (CompositeResult) result;
        List<Result> results = compositeResult.getResults();
        StringBuilder buffer = new StringBuilder();
        for (Result childResult : results) {
            String childResultMessage = getResultMessage(childResult);
            if (Strings.isNotBlank(childResultMessage)) {
                if (buffer.length() > 0) {
                    buffer.append("\n");
                }
                buffer.append(childResultMessage);
            }
        }
        return buffer.toString();
    } else if (result != null) {
        return result.getMessage();
    } else {
        return null;
    }
}
 
Example 15
Source Project: fabric8-forge   Source File: NodeDtoSupport.java    License: Apache License 2.0 6 votes vote down vote up
public void defaultKey(NodeDto owner, Map<String, Integer> nodeCounts) {
    String elementName = getPattern();
    Integer countObject = nodeCounts.get(elementName);
    int count = countObject != null ? countObject : 0;
    nodeCounts.put(elementName, ++count);
    if (Strings.isNullOrBlank(key)) {
        key = owner.getKey();
        if (Strings.isNullOrBlank(key)) {
            key = "";
        } else {
            key += "/";
        }
        if (Strings.isNotBlank(id)) {
            key += id;
        } else {
            key += "_" + elementName + count;
        }
    }
}
 
Example 16
Source Project: fabric8-forge   Source File: CamelXmlHelper.java    License: Apache License 2.0 6 votes vote down vote up
protected static List<ContextDto> parseCamelContexts(CamelCatalog camelCatalog, File xmlFile) throws Exception {
    List<ContextDto> camelContexts = new ArrayList<>();

    RouteXml routeXml = new RouteXml();
    XmlModel xmlModel = routeXml.unmarshal(xmlFile);

    // TODO we don't handle multiple contexts inside an XML file!
    CamelContextFactoryBean contextElement = xmlModel.getContextElement();
    String name = contextElement.getId();
    List<RouteDefinition> routeDefs = contextElement.getRoutes();
    ContextDto context = new ContextDto(name);
    camelContexts.add(context);
    String key = name;
    if (Strings.isNullOrBlank(key)) {
        key = "_camelContext" + camelContexts.size();
    }
    context.setKey(key);
    List<NodeDto> routes = createRouteDtos(camelCatalog, routeDefs, context);
    context.setChildren(routes);
    return camelContexts;
}
 
Example 17
Source Project: fabric8-forge   Source File: CamelXmlHelper.java    License: Apache License 2.0 6 votes vote down vote up
private static String getIdOrIndex(Node node, Map<String, Integer> nodeCounts) {
    String answer = null;
    if (node instanceof Element) {
        Element element = (Element) node;
        String elementName = element.getTagName();
        if ("routes".equals(elementName)) {
            elementName = "camelContext";
        }
        Integer countObject = nodeCounts.get(elementName);
        int count = countObject != null ? countObject.intValue() : 0;
        nodeCounts.put(elementName, ++count);
        answer = element.getAttribute("id");
        if (Strings.isNullOrBlank(answer)) {
            answer = "_" + elementName + count;
        }
    }
    return answer;
}
 
Example 18
Source Project: ipaas-quickstarts   Source File: CatalogBuilder.java    License: Apache License 2.0 6 votes vote down vote up
protected Set<String> loadArchetypesPomArtifactIds(File archetypesPomFile) throws IOException {
    Set<String> answer = new TreeSet<>();
    if (!archetypesPomFile.isFile() || !archetypesPomFile.exists()) {
        LOG.warn("archetypes pom.xml file does not exist!: " + archetypesPomFile);
        return null;

    }
    try {
        Document doc = archetypeUtils.parseXml(new InputSource(new FileReader(archetypesPomFile)));
        Element root = doc.getDocumentElement();

        // lets load all the properties defined in the <properties> element in the bom pom.
        NodeList moduleElements = root.getElementsByTagName("module");
        for (int i = 0, size = moduleElements.getLength(); i < size; i++) {
            Element moduleElement = (Element) moduleElements.item(i);
            String module = moduleElement.getTextContent();
            if (Strings.isNotBlank(module)) {
                answer.add(module);
            }
        }
        LOG.info("Loaded archetypes module names: "+ answer);
        return answer;
    } catch (FileNotFoundException e) {
        throw new IOException("Failed to parse " + archetypesPomFile + ". " + e, e);
    }
}
 
Example 19
@Override
public String run() throws Exception {

    if (Strings.isNullOrBlank(step.getApp())) {
        throw new AbortException("No App name provided");
    }

    if (Strings.isNullOrBlank(step.getEnvironment())) {
        throw new AbortException("No environment name provided");
    }
    ApprovalEventDTO approval = new ApprovalEventDTO();
    approval.setApp(step.getApp());
    approval.setEnvironment(step.getEnvironment());
    approval.setRequestedTime(new Date());

    String json = mapper.writeValueAsString(approval);

    return ElasticsearchClient.createEvent(json, ElasticsearchClient.APPROVE, listener);

}
 
Example 20
@Override
public String run() throws Exception {

    if (step.getApproved() == null) {
        throw new AbortException("No Approved boolean set");
    }

    if (Strings.isNullOrBlank(step.getId())) {
        // if we dont have an id to update ignore the request as it's likely elasticsearch isn't running
        listener.getLogger().println("No approve event id found.  Skipping approval event update request");
        return OK;
    }
    ApprovalEventDTO approval = new ApprovalEventDTO();
    approval.setApproved(step.getApproved());
    approval.setReceivedTime(new Date());

    String json = mapper.writeValueAsString(approval);

    Boolean success = ElasticsearchClient.updateEvent(step.getId(), json, ElasticsearchClient.APPROVE, listener);
    if (!success){
        throw new AbortException("Error updating Approve event id ["+step.getId()+"]");
    }

    return OK;

}
 
Example 21
@Override
public String run() throws Exception {

    String json = step.getJson();
    String index = step.getIndex();

    if (Strings.isNullOrBlank(json)) {
        throw new AbortException("No JSON payload found");
    }
    // validate JSON structure
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.readTree(json);

    String id = ElasticsearchClient.createEvent(json, index, listener);
    if (Strings.isNullOrBlank(id)){
        throw new AbortException("Error creating event in elasticsearch");
    }

    return id;

}
 
Example 22
Source Project: ipaas-quickstarts   Source File: ArchetypeTest.java    License: Apache License 2.0 6 votes vote down vote up
protected List<String> getArchetypesFromJar() throws IOException {
    String entryName = "archetype-catalog.xml";
    URL url = getClass().getClassLoader().getResource(entryName);
    assertThat(url).describedAs("Could not find resource " + entryName + " on the classpath!").isNotNull();

    SortedSet<String> artifactIds = new TreeSet<>();
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputSource is = new InputSource(url.openStream());
        Document doc = builder.parse(is);
        NodeList artifactTags = doc.getElementsByTagName("artifactId");
        for (int i = 0, size = artifactTags.getLength(); i < size; i++) {
            Node element = artifactTags.item(i);
            String artifactId = element.getTextContent();
            if (Strings.isNotBlank(artifactId)) {
                artifactIds.add(artifactId);
            }
        }
    } catch (Exception e) {
        fail("Failed to parse " + entryName + " in catalog " + url + ". Exception " + e, e);
    }
    return new ArrayList<>(artifactIds);
}
 
Example 23
Source Project: updatebot   Source File: CommandSupport.java    License: Apache License 2.0 5 votes vote down vote up
private void appendPullRequestsCommentArguments(StringBuilder builder, List<Field> fields, boolean namedArguments) {
    for (Field field : fields) {
        Parameter parameter = field.getAnnotation(Parameter.class);
        String[] names = parameter.names();
        if (names.length > 0) {
            String name = names[0];
            if (!namedArguments) {
                continue;
            }
            builder.append(" ");
            builder.append(name);
        } else {
            if (namedArguments) {
                continue;
            }
        }
        Object value = getFieldValue(field, this);
        if (value != null) {
            builder.append(" ");
            if (value instanceof Collection) {
                builder.append(Strings.join((Collection) value, " "));
            } else if (value instanceof Object[]) {
                builder.append(Strings.join(" ", (Object[]) value));
            } else {
                builder.append(value);
            }
        }
    }
}
 
Example 24
Source Project: updatebot   Source File: GitHelper.java    License: Apache License 2.0 5 votes vote down vote up
protected static String stripSlashesAndGit(String path) {
    path = Strings.stripPrefix(path, "/");
    path = Strings.stripPrefix(path, "/");
    path = Strings.stripSuffix(path, "/");
    path = Strings.stripSuffix(path, ".git");
    return path;
}
 
Example 25
Source Project: ipaas-quickstarts   Source File: ArchetypeTest.java    License: Apache License 2.0 5 votes vote down vote up
protected static int invokeMaven(String[] args, String outDir, File logFile) {
    List<String> goals = Arrays.asList(args);
    String commandLine = Strings.join(goals, " ");

    InvocationResult result = null;
    try {
        File dir = new File(outDir);

        InvocationRequest request = new DefaultInvocationRequest();
        request.setGoals(goals);

        InvocationOutputHandler outputHandler = new SystemOutAndFileHandler(logFile);
        outputHandler.consumeLine("");
        outputHandler.consumeLine("");
        outputHandler.consumeLine(dir.getName() + " : starting: mvn " + commandLine);
        outputHandler.consumeLine("");
        request.setOutputHandler(outputHandler);
        request.setErrorHandler(outputHandler);

        DefaultInvoker invoker = new DefaultInvoker();
        request.setPomFile(new File(dir, "pom.xml"));
        result = invoker.execute(request);
        CommandLineException executionException = result.getExecutionException();
        if (executionException != null) {
            LOG.error("Failed to invoke maven with: mvn " + commandLine + ". " + executionException, executionException);
        }
    } catch (Exception e) {
        LOG.error("Failed to invoke maven with: mvn " + commandLine + ". " + e, e);
    }
    return result == null ? 1 : result.getExitCode();
}
 
Example 26
Source Project: updatebot   Source File: VersionHelper.java    License: Apache License 2.0 5 votes vote down vote up
public static String getVersion(String groupId, String artifactId, String defaultVersion) {
    String answer = getVersion(groupId, artifactId);
    if (Strings.isNullOrBlank(answer)) {
        answer = defaultVersion;
    }

    return answer;
}
 
Example 27
Source Project: updatebot   Source File: ProcessHelper.java    License: Apache License 2.0 5 votes vote down vote up
protected static void logOutput(String output, boolean error) {
    if (Strings.notEmpty(output)) {
        String[] lines = output.split("\n");
        for (String line : lines) {
            if (error) {
                LOG.error(line);
            } else {
                LOG.info(line);
            }
        }
    }
}
 
Example 28
Source Project: updatebot   Source File: ProcessHelper.java    License: Apache License 2.0 5 votes vote down vote up
protected static void logOutput(Configuration configuration, Logger log, String output, boolean error) {
    if (Strings.notEmpty(output)) {
        String[] lines = output.split("\n");
        for (String line : lines) {
            if (error) {
                configuration.error(log, line);
            } else {
                configuration.info(log, line);
            }
        }
    }
}
 
Example 29
Source Project: fabric8-forge   Source File: PopulateMavenRepositoryTest.java    License: Apache License 2.0 5 votes vote down vote up
protected void createProjects(Furnace furnace) throws Exception {
    File projectsOutputFolder = new File(baseDir, "target/createdProjects");
    Files.recursiveDelete(projectsOutputFolder);

    ProjectGenerator generator = new ProjectGenerator(furnace, projectsOutputFolder, localMavenRepo);
    File archetypeJar = generator.getArtifactJar("io.fabric8.archetypes", "archetypes-catalog", ProjectGenerator.FABRIC8_ARCHETYPE_VERSION);

    List<String> archetypes = getArchetypesFromJar(archetypeJar);
    assertThat(archetypes).describedAs("Archetypes to create").isNotEmpty();

    String testArchetype = System.getProperty(TEST_ARCHETYPE_SYSTEM_PROPERTY, "");
    if (Strings.isNotBlank(testArchetype)) {
        LOG.info("Due to system property: '" + TEST_ARCHETYPE_SYSTEM_PROPERTY + "' we will just run the test on archetype: " + testArchetype);
        generator.createProjectFromArchetype(testArchetype);
    } else {
        for (String archetype : archetypes) {
            // TODO fix failing archetypes...
            if (!archetype.startsWith("jboss-fuse-") && !archetype.startsWith("swarm")) {
                generator.createProjectFromArchetype(archetype);
            }
        }
    }

    removeSnapshotFabric8Artifacts();


    List<File> failedFolders = generator.getFailedFolders();
    if (failedFolders.size() > 0) {
        LOG.error("Failed to build all the projects!!!");
        for (File failedFolder : failedFolders) {
            LOG.error("Failed to build project: " + failedFolder.getName());
        }
    }
}
 
Example 30
Source Project: fabric8-forge   Source File: ForgeClient.java    License: Apache License 2.0 5 votes vote down vote up
public String getNamespace() {
    if (Strings.isNullOrBlank(namespace)) {
        namespace = kubernetesClient.getNamespace();
    }
    if (Strings.isNullOrBlank(namespace)) {
        namespace = KubernetesHelper.defaultNamespace();
    }
    if (Strings.isNullOrBlank(namespace)) {
        namespace = "default";
    }
    return namespace;
}