use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultConfiguration method extendsFrom.
public Configuration extendsFrom(Configuration... extendsFrom) {
validateMutation(MutationType.DEPENDENCIES);
for (Configuration configuration : extendsFrom) {
if (configuration.getHierarchy().contains(this)) {
throw new InvalidUserDataException(String.format("Cyclic extendsFrom from %s and %s is not allowed. See existing hierarchy: %s", this, configuration, configuration.getHierarchy()));
}
if (this.extendsFrom.add(configuration)) {
inheritedArtifacts.addCollection(configuration.getAllArtifacts());
inheritedDependencies.addCollection(configuration.getAllDependencies());
((ConfigurationInternal) configuration).addMutationValidator(parentMutationValidator);
}
}
return this;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class ComponentModuleMetadataContainer method detectCycles.
private static void detectCycles(Map<ModuleIdentifier, ModuleIdentifier> replacements, ModuleIdentifier source, ModuleIdentifier target) {
if (source.equals(target)) {
throw new InvalidUserDataException(String.format("Cannot declare module replacement that replaces self: %s->%s", source, target));
}
ModuleIdentifier m = replacements.get(target);
if (m == null) {
//target does not exist in the map, there's no cycle for sure
return;
}
Set<ModuleIdentifier> visited = new LinkedHashSet<ModuleIdentifier>();
visited.add(source);
visited.add(target);
while (m != null) {
if (!visited.add(m)) {
//module was already visited, there is a cycle
throw new InvalidUserDataException(format("Cannot declare module replacement %s->%s because it introduces a cycle: %s", source, target, Joiner.on("->").join(visited) + "->" + source));
}
m = replacements.get(m);
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class JUnitTestClassExecuter method runTestClass.
private void runTestClass(String testClassName) throws ClassNotFoundException {
final Class<?> testClass = Class.forName(testClassName, false, applicationClassLoader);
List<Filter> filters = new ArrayList<Filter>();
if (options.hasCategoryConfiguration()) {
verifyJUnitCategorySupport();
Transformer<Class<?>, String> transformer = new Transformer<Class<?>, String>() {
public Class<?> transform(final String original) {
try {
return applicationClassLoader.loadClass(original);
} catch (ClassNotFoundException e) {
throw new InvalidUserDataException(String.format("Can't load category class [%s].", original), e);
}
}
};
filters.add(new CategoryFilter(CollectionUtils.collect(options.getIncludeCategories(), transformer), CollectionUtils.collect(options.getExcludeCategories(), transformer)));
}
Request request = Request.aClass(testClass);
Runner runner = request.getRunner();
if (!options.getIncludedTests().isEmpty()) {
TestSelectionMatcher matcher = new TestSelectionMatcher(options.getIncludedTests());
// matches the filter, run the entire suite instead of filtering away its contents.
if (!runner.getDescription().isSuite() || !matcher.matchesTest(testClassName, null)) {
filters.add(new MethodNameFilter(matcher));
}
}
if (runner instanceof Filterable) {
Filterable filterable = (Filterable) runner;
for (Filter filter : filters) {
try {
filterable.filter(filter);
} catch (NoTestsRemainException e) {
// Ignore
return;
}
}
} else if (allTestsFiltered(runner, filters)) {
return;
}
RunNotifier notifier = new RunNotifier();
notifier.addListener(listener);
runner.run(notifier);
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class BasePomFilterContainer method addFilter.
public MavenPom addFilter(String name, PublishFilter publishFilter) {
if (name == null || publishFilter == null) {
throw new InvalidUserDataException("Name and Filter must not be null.");
}
MavenPom pom = mavenPomFactory.create();
pomFilters.put(name, new DefaultPomFilter(name, pom, publishFilter));
return pom;
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultArtifactPom method addArtifact.
public void addArtifact(Artifact artifact, File src) {
throwExceptionIfArtifactOrSrcIsNull(artifact, src);
PublishArtifact publishArtifact = new MavenArtifact(artifact, src);
ArtifactKey artifactKey = new ArtifactKey(publishArtifact);
if (this.artifacts.containsKey(artifactKey)) {
throw new InvalidUserDataException(String.format("A POM cannot have multiple artifacts with the same type and classifier. Already have %s, trying to add %s.", this.artifacts.get(artifactKey), publishArtifact));
}
if (publishArtifact.getClassifier() != null) {
addArtifact(publishArtifact);
assignArtifactValuesToPom(artifact, pom, false);
return;
}
if (this.artifact != null) {
// Choose the 'main' artifact based on its type.
if (!PACKAGING_TYPES.contains(artifact.getType())) {
addArtifact(publishArtifact);
return;
}
if (PACKAGING_TYPES.contains(this.artifact.getType())) {
throw new InvalidUserDataException("A POM can not have multiple main artifacts. " + "Already have " + this.artifact + ", trying to add " + publishArtifact);
}
addArtifact(this.artifact);
}
this.artifact = publishArtifact;
this.artifacts.put(artifactKey, publishArtifact);
assignArtifactValuesToPom(artifact, pom, true);
}
Aggregations