org.apache.maven.model.io.DefaultModelReader Java Examples

The following examples show how to use org.apache.maven.model.io.DefaultModelReader. 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: DependencyResolver.java    From spring-init with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(ModelLocator.class).to(DefaultModelLocator.class).in(Singleton.class);
	bind(ModelReader.class).to(DefaultModelReader.class).in(Singleton.class);
	bind(ModelValidator.class).to(DefaultModelValidator.class).in(Singleton.class);
	bind(RepositoryConnectorFactory.class).to(BasicRepositoryConnectorFactory.class)
			.in(Singleton.class);
	bind(ArtifactDescriptorReader.class) //
			.to(DefaultArtifactDescriptorReader.class).in(Singleton.class);
	bind(VersionResolver.class) //
			.to(DefaultVersionResolver.class).in(Singleton.class);
	bind(VersionRangeResolver.class) //
			.to(DefaultVersionRangeResolver.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("snapshot")) //
			.to(SnapshotMetadataGeneratorFactory.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("versions")) //
			.to(VersionsMetadataGeneratorFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("http"))
			.to(HttpTransporterFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("file"))
			.to(FileTransporterFactory.class).in(Singleton.class);
}
 
Example #2
Source File: Resolver.java    From migration-tooling with Apache License 2.0 6 votes vote down vote up
/**
 * Given a local path to a Maven project, this attempts to find the transitive dependencies of the
 * project.
 *
 * @param projectPath The path to search for Maven projects.
 * @param scopes The scopes to look up dependencies in.
 */
public String resolvePomDependencies(String projectPath, Set<String> scopes) {
  DefaultModelProcessor processor = new DefaultModelProcessor();
  processor.setModelLocator(new DefaultModelLocator());
  processor.setModelReader(new DefaultModelReader());
  File pom = processor.locatePom(new File(projectPath));
  FileModelSource pomSource = new FileModelSource(pom);
  // First resolve the model source locations.
  resolveSourceLocations(pomSource);
  // Next, fully resolve the models.
  Model model = modelResolver.getEffectiveModel(pomSource);
  if (model != null) {
    traverseDeps(model, scopes, Sets.newHashSet(), null);
  }
  return pom.getAbsolutePath();
}
 
Example #3
Source File: DependencyResolver.java    From spring-cloud-function with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
	bind(ModelLocator.class).to(DefaultModelLocator.class).in(Singleton.class);
	bind(ModelReader.class).to(DefaultModelReader.class).in(Singleton.class);
	bind(ModelValidator.class).to(DefaultModelValidator.class).in(Singleton.class);
	bind(RepositoryConnectorFactory.class).to(BasicRepositoryConnectorFactory.class)
			.in(Singleton.class);
	bind(ArtifactDescriptorReader.class) //
			.to(DefaultArtifactDescriptorReader.class).in(Singleton.class);
	bind(VersionResolver.class) //
			.to(DefaultVersionResolver.class).in(Singleton.class);
	bind(VersionRangeResolver.class) //
			.to(DefaultVersionRangeResolver.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("snapshot")) //
			.to(SnapshotMetadataGeneratorFactory.class).in(Singleton.class);
	bind(MetadataGeneratorFactory.class).annotatedWith(Names.named("versions")) //
			.to(VersionsMetadataGeneratorFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("http"))
			.to(HttpTransporterFactory.class).in(Singleton.class);
	bind(TransporterFactory.class).annotatedWith(Names.named("file"))
			.to(FileTransporterFactory.class).in(Singleton.class);
}
 
Example #4
Source File: MavenPluginHelper.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
public MavenProject newMavenProject(String pom, File dir)
        throws IOException {

    File pomFile = getTestFile("src/test/resources/" + pom);
    org.apache.maven.model.Model model = new DefaultModelReader()
            .read(pomFile, Collections.emptyMap());
    model.getBuild().setDirectory(dir.getAbsolutePath());
    MavenProject project = new MavenProject(model);
    project.getProperties().put("project.build.sourceEncoding", "UTF-8");
    project.setFile(pomFile);
    return project;
}
 
Example #5
Source File: MavenPluginHelper.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
public MavenProject newMavenProject(String pom, File dir)
        throws IOException {

    File pomFile = getTestFile("src/test/resources/" + pom);
    org.apache.maven.model.Model model = new DefaultModelReader()
            .read(pomFile, Collections.emptyMap());
    model.getBuild().setDirectory(dir.getAbsolutePath());
    MavenProject project = new MavenProject(model);
    project.getProperties().put("project.build.sourceEncoding", "UTF-8");
    project.setFile(pomFile);
    return project;
}
 
Example #6
Source File: ModelReaderTest.java    From JQF with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Fuzz
public void testWithInputStream(InputStream in) {
    ModelReader reader = new DefaultModelReader();
    try {
        Model model = reader.read(in, null);
        Assert.assertNotNull(model);
    } catch (IOException e) {
        Assume.assumeNoException(e);
    }
}
 
Example #7
Source File: ChangeManager.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public ChangeManager ( final Log log )
{
    this.log = log;
    this.writer = new DefaultModelWriter ();
    this.reader = new DefaultModelReader ();
}