Java Code Examples for io.fabric8.utils.Strings#stripSuffix()
The following examples show how to use
io.fabric8.utils.Strings#stripSuffix() .
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 File: GitHelper.java From updatebot with Apache License 2.0 | 5 votes |
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 2
Source File: CamelModelHelper.java From fabric8-forge with Apache License 2.0 | 5 votes |
/** * Returns the pattern name */ public static String getPatternName(OptionalIdentifiedDefinition camelNode) { // we should grab the annotation instead XmlRootElement root = camelNode.getClass().getAnnotation(XmlRootElement.class); if (root != null) { return root.name(); } String simpleName = Strings.stripSuffix(camelNode.getClass().getSimpleName(), "Definition"); return Introspector.decapitalize(simpleName); }
Example 3
Source File: PomValidator.java From ipaas-quickstarts with Apache License 2.0 | 5 votes |
protected void validatePom(String projectName, File pom) { LOG.debug("Validating " + pom); String prefix = "quickstart " + Strings.stripSuffix(projectName, "-archetype") + " pom.xml"; Element root = null; try { Document doc = archetypeUtils.parseXml(new InputSource(new FileReader(pom))); root = doc.getDocumentElement(); } catch (Exception e) { LOG.error("Failed to parse " + pom + ". " + e, e); return; } if (root == null) { return; } Element propertyElement = getPropertiesElement(root); // lets load all the properties defined in the <properties> element in the bom pom. NodeList dependencyElements = root.getElementsByTagName("dependency"); for (int i = 0, size = dependencyElements.getLength(); i < size; i++) { Element dependency = (Element) dependencyElements.item(i); validateVersion(prefix + " dependency", dependency, propertyElement); } NodeList pluginElements = root.getElementsByTagName("plugin"); for (int i = 0, size = pluginElements.getLength(); i < size; i++) { Element plugin = (Element) pluginElements.item(i); validateVersion(prefix + " plugin", plugin, propertyElement); } }
Example 4
Source File: GitRepository.java From updatebot with Apache License 2.0 | 4 votes |
public GitRepository(String name, String cloneUrl) { this.name = name; this.cloneUrl = cloneUrl; this.htmlUrl = Strings.stripSuffix(cloneUrl, ".git"); }
Example 5
Source File: ProjectGenerator.java From fabric8-forge with Apache License 2.0 | 4 votes |
public void createProjectFromArchetype(String archetype) throws Exception { String archetypeUri = "io.fabric8.archetypes:" + archetype + ":" + FABRIC8_ARCHETYPE_VERSION; LOG.info("Creating archetype: " + archetypeUri); RestUIContext context = new RestUIContext(); UICommand projectNewCommand = commandFactory.getCommandByName(context, "project-new"); File outputDir = new File(projectsOutputFolder, archetype); outputDir.mkdirs(); CommandController controller = commandControllerFactory.createController(context, runtime, projectNewCommand); controller.initialize(); String name = Strings.stripSuffix("my-" + archetype, "-archetype"); controller.setValueFor("named", name); controller.setValueFor("topLevelPackage", "org.example"); controller.setValueFor("version", "1.0.0-SNAPSHOT"); controller.setValueFor("targetLocation", outputDir.getAbsolutePath()); controller.setValueFor("buildSystem", "Maven"); controller.setValueFor("type", "From Archetype Catalog"); WizardCommandController wizardCommandController = assertWizardController(controller); validate(wizardCommandController); wizardCommandController = wizardCommandController.next(); LOG.info("Next result: " + wizardCommandController); /* InputComponent<?, ?> archetypeInput = wizardCommandController.getInputs().get("archetype"); archetypeInput.get */ wizardCommandController.setValueFor("catalog", "fabric8"); wizardCommandController.setValueFor("archetype", archetypeUri); validate(wizardCommandController); try { Result result = wizardCommandController.execute(); printResult(result); useProjectFromArchetype(archetype, outputDir, name); } catch (Exception e) { LOG.error("Failed to create project " + archetypeUri + " " + e, e); } }
Example 6
Source File: ArchetypeTest.java From ipaas-quickstarts with Apache License 2.0 | 4 votes |
private void assertArchetypeCreated(String artifactId, String groupId, String version, File archetypejar) throws Exception { artifactId = Strings.stripSuffix(artifactId, "-archetype"); artifactId = Strings.stripSuffix(artifactId, "-example"); File outDir = new File(projectsOutputFolder, artifactId); LOG.info("Creating Archetype " + groupId + ":" + artifactId + ":" + version); Map<String, String> properties = new ArchetypeHelper(archetypejar, outDir, groupId, artifactId, version, null, null).parseProperties(); LOG.info("Has preferred properties: " + properties); ArchetypeHelper helper = new ArchetypeHelper(archetypejar, outDir, groupId, artifactId, version, null, null); helper.setPackageName(packageName); // lets override some properties HashMap<String, String> overrideProperties = new HashMap<String, String>(); // for camel-archetype-component overrideProperties.put("scheme", "mycomponent"); helper.setOverrideProperties(overrideProperties); // this is where the magic happens helper.execute(); LOG.info("Generated archetype " + artifactId); // expected pom file File pom = new File(outDir, "pom.xml"); // this archetype might not be a maven project if (!pom.isFile()) { return; } String pomText = Files.toString(pom); String badText = "${camel-"; if (pomText.contains(badText)) { if (verbose) { LOG.info(pomText); } fail("" + pom + " contains " + badText); } // now lets ensure we have the necessary test dependencies... boolean updated = false; Document doc = XmlUtils.parseDoc(pom); boolean funktion = isFunktionProject(doc); LOG.debug("Funktion project: " + funktion); if (!funktion) { if (ensureMavenDependency(doc, "io.fabric8", "fabric8-arquillian", "test")) { updated = true; } if (ensureMavenDependency(doc, "org.jboss.arquillian.junit", "arquillian-junit-container", "test")) { updated = true; } if (ensureMavenDependency(doc, "org.jboss.shrinkwrap.resolver", "shrinkwrap-resolver-impl-maven", "test")) { updated = true; } if (ensureMavenDependencyBOM(doc, "io.fabric8", "fabric8-project-bom-with-platform-deps", fabric8Version)) { updated = true; } } if (ensureFailsafePlugin(doc)) { updated = true; } if (updated) { DomHelper.save(doc, pom); } // lets generate the system test if (!hasGoodSystemTest(new File(outDir, "src/test/java"))) { File systemTest = new File(outDir, "src/test/java/io/fabric8/systests/KubernetesIntegrationKT.java"); systemTest.getParentFile().mkdirs(); String javaFileName = "KubernetesIntegrationKT.java"; URL javaUrl = getClass().getClassLoader().getResource(javaFileName); assertNotNull("Could not load resource on the classpath: " + javaFileName, javaUrl); IOHelpers.copy(javaUrl.openStream(), new FileOutputStream(systemTest)); } outDirs.add(outDir.getPath()); }