
nl.praegus.fitnesse.symbols.MavenProjectVersions.ProjectDependencyInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of toolchain-fitnesse-plugin Show documentation
Show all versions of toolchain-fitnesse-plugin Show documentation
Auto-register autocomplete responder and add debug script table
package nl.praegus.fitnesse.symbols.MavenProjectVersions;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
public class ProjectDependencyInfo {
private final List dependenciesInfo = new ArrayList<>();
private final static Set IGNORE_DEPENDENCIES = new HashSet<>(Arrays.asList(
"jaxb-core",
"jaxb-impl",
"jaxb-api",
"activation",
"junit"
));
public ProjectDependencyInfo() throws FileNotFoundException {
fillListWithDependencyInfo("/../pom.xml");
}
public ProjectDependencyInfo(String pomUrl) throws FileNotFoundException {
fillListWithDependencyInfo(pomUrl);
}
private void fillListWithDependencyInfo(String pomUrl) throws FileNotFoundException {
// Add plugin information
dependenciesInfo.add(new DependencyInfo("nl.praegus", "toolchain-fitnesse-plugin"));
// Add Dependency information
try {
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(new FileReader(System.getProperty("user.dir") + pomUrl));
List dependencies = model.getDependencies();
for (Dependency dep : dependencies) {
String artifact = dep.getArtifactId();
if (!IGNORE_DEPENDENCIES.contains(artifact)) {
dependenciesInfo.add(new DependencyInfo(dep.getGroupId(), artifact, dep.getVersion(), model));
}
}
} catch (IOException | XmlPullParserException ignored) {
throw new FileNotFoundException("POM not found!");
}
}
public List getDependencyInfo() {
return dependenciesInfo;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy