com.exasol.projectkeeper.sources.SourceAnalyzer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of project-keeper-core Show documentation
Show all versions of project-keeper-core Show documentation
Project keeper is a tool that verifies and fixes project setups.
package com.exasol.projectkeeper.sources;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
import java.nio.file.Path;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.exasol.errorreporting.ExaError;
import com.exasol.projectkeeper.shared.config.*;
import com.exasol.projectkeeper.sources.analyze.LanguageSpecificSourceAnalyzer;
import com.exasol.projectkeeper.sources.analyze.MavenSourceAnalyzer;
import com.exasol.projectkeeper.sources.analyze.golang.GolangSourceAnalyzer;
import com.exasol.projectkeeper.sources.analyze.npm.NpmSourceAnalyzer;
/**
* This class analyzes source projects of any type by calling the relevant {@link LanguageSpecificSourceAnalyzer}.
*/
public class SourceAnalyzer {
private final Map sourceAnalyzers;
SourceAnalyzer(final Map sourceAnalyzers) {
this.sourceAnalyzers = sourceAnalyzers;
}
/**
* Creates a new instance of {@link SourceAnalyzer}, configuring the available
* {@link LanguageSpecificSourceAnalyzer}s.
*
* @param config project keeper configuration passed to the {@link LanguageSpecificSourceAnalyzer}s if necessary
* @param mvnRepo the path to the maven repository, may be {@code null} if the default should be used
* @param ownVersion the version of this running project keeper instance
* @return a new configured {@link SourceAnalyzer}
*/
public static SourceAnalyzer create(final ProjectKeeperConfig config, final Path mvnRepo, final String ownVersion) {
return new SourceAnalyzer(getLanguageSpecificSourceAnalyzers(config, mvnRepo, ownVersion));
}
private static Map getLanguageSpecificSourceAnalyzers(
final ProjectKeeperConfig config, final Path mvnRepo, final String ownVersion) {
return Map.of( //
SourceType.MAVEN, new MavenSourceAnalyzer(mvnRepo, ownVersion), //
SourceType.GOLANG, new GolangSourceAnalyzer(config), //
SourceType.NPM, new NpmSourceAnalyzer());
}
/**
* Analyze a list of source projects, potentially of mixed type (e.g. Maven and Golang).
*
* @param projectDir project directory
* @param sources configured sources
* @return analyzed sources in the same order as the input
*/
public List analyze(final Path projectDir, final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy