/** * Reads model from given path. The behaviour is same to {@link #readFrom(java.io.File)} * * @param path to read from * @return fetched model * @throws NullPointerException when given {@code path} is {@code null} * @throws IOException if any i/o error occurs * @throws org.eclipse.che.commons.xml.XMLTreeException when input stream contains not valid xml * content */ public static Model readFrom(Path path) throws IOException { return readFrom(requireNonNull(path.toFile(), "Required not null model")); }
/** * Get description of maven project and all its modules if any as plain list. * * @param sources maven project directory. Note: Must contains pom.xml file. * @return description of maven project * @throws IOException if an i/o error occurs */ public static List<Model> getModules(java.io.File sources) throws IOException { final LinkedList<Model> modules = new LinkedList<>(); addModules(Model.readFrom(sources), modules); return modules; }
/** Get resource directories. */ public static List<String> getResourceDirectories(java.io.File pom) throws IOException { return getResourceDirectories(Model.readFrom(pom)); }
/** Get source directories. */ public static List<String> getSourceDirectories(java.io.File pom) throws IOException { return getSourceDirectories(Model.readFrom(pom)); }
/** * Reads model from given file, or if given file is a directory reads model from the * <i>pom.xml</i> which is under the given directory * * <p>After reading from pom file model will be associated with it, so {@link #getPomFile()} and * will return pom file and {@link #getProjectDirectory()} will return pom file parent directory. * * @param file <i>pom.xml</i> to read model from or its parent directory * @return fetched model * @throws IOException if any i/o error occurs * @throws org.eclipse.che.commons.xml.XMLTreeException when input stream contains not valid xml * content * @throws NullPointerException when given {@code file} is {@code null} */ public static Model readFrom(File file) throws IOException { requireNonNull(file, "Required not null file"); if (file.isDirectory()) { return readFrom(new File(file, "pom.xml")); } return fetchModel(XMLTree.from(file)).setPomFile(file); }
0, gwtModuleName.length() - GwtXmlUtils.GWT_MODULE_XML_SUFFIX.length()); Model pom = Model.readFrom(zipFile.getInputStream(pomEntry)); return new Extension( gwtModuleName,
private static void addModules(Model model, List<Model> modules) throws IOException { if (!"pom".equals(model.getPackaging())) return; for (String module : model.getModules()) { final Path modulePom = model.getProjectDirectory().toPath().resolve(module).resolve("pom.xml"); if (exists(modulePom)) { final Model child = Model.readFrom(modulePom); final String relativePath = modulePom.getParent().relativize(model.getPomFile().toPath()).toString(); child.setParent( new Parent(model.getGroupId(), model.getArtifactId(), model.getVersion()) .setRelativePath(relativePath)); modules.add(child); addModules(child, modules); } } }
for (Extension extension : extensions) { final File pom = extResourcesWorkDirPath.resolve("pom.xml").toFile(); final Model model = Model.readFrom(pom); model .dependencies()