本文整理汇总了Java中org.gradle.api.InvalidUserDataException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidUserDataException类的具体用法?Java InvalidUserDataException怎么用?Java InvalidUserDataException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InvalidUserDataException类属于org.gradle.api包,在下文中一共展示了InvalidUserDataException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publish
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
@TaskAction
public void publish() {
final MavenPublicationInternal publication = getPublicationInternal();
if (publication == null) {
throw new InvalidUserDataException("The 'publication' property is required");
}
new PublishOperation(publication, "mavenLocal") {
@Override
protected void publish() throws Exception {
MavenPublisher localPublisher = new MavenLocalPublisher(getLoggingManagerFactory(), getMavenRepositoryLocator());
MavenPublisher staticLockingPublisher = new StaticLockingMavenPublisher(localPublisher);
MavenPublisher validatingPublisher = new ValidatingMavenPublisher(staticLockingPublisher);
validatingPublisher.publish(publication.asNormalisedPublication(), null);
}
}.run();
}
示例2: from
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public void from(SoftwareComponent component) {
if (this.component != null) {
throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name));
}
this.component = (SoftwareComponentInternal) component;
for (Usage usage : this.component.getUsages()) {
// TODO Need a smarter way to map usage to artifact classifier
for (PublishArtifact publishArtifact : usage.getArtifacts()) {
artifact(publishArtifact);
}
// TODO Need a smarter way to map usage to scope
for (ModuleDependency dependency : usage.getDependencies()) {
if (dependency instanceof ProjectDependency) {
addProjectDependency((ProjectDependency) dependency);
} else {
addModuleDependency(dependency);
}
}
}
}
示例3: detectCycles
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
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);
}
}
示例4: convert
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public void convert(String notation, NotationConvertResult<? super ModuleVersionSelector> result) throws TypeConversionException {
ParsedModuleStringNotation parsed;
try {
parsed = new ParsedModuleStringNotation(notation, null);
} catch (IllegalDependencyNotation e) {
throw new InvalidUserDataException(
"Invalid format: '" + notation + "'. The correct notation is a 3-part group:name:version notation, "
+ "e.g: 'org.gradle:gradle-core:1.0'");
}
if (parsed.getGroup() == null || parsed.getName() == null || parsed.getVersion() == null) {
throw new InvalidUserDataException(
"Invalid format: '" + notation + "'. Group, name and version cannot be empty. Correct example: "
+ "'org.gradle:gradle-core:1.0'");
}
result.converted(newSelector(parsed.getGroup(), parsed.getName(), parsed.getVersion()));
}
示例5: convert
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public void convert(String notation, NotationConvertResult<? super ComponentSelector> result) throws TypeConversionException {
ParsedModuleStringNotation parsed;
try {
parsed = new ParsedModuleStringNotation(notation, null);
} catch (IllegalDependencyNotation e) {
throw new InvalidUserDataException(
"Invalid format: '" + notation + "'. The correct notation is a 3-part group:name:version notation, "
+ "e.g: 'org.gradle:gradle-core:1.0'");
}
if (parsed.getGroup() == null || parsed.getName() == null || parsed.getVersion() == null) {
throw new InvalidUserDataException(
"Invalid format: '" + notation + "'. Group, name and version cannot be empty. Correct example: "
+ "'org.gradle:gradle-core:1.0'");
}
result.converted(newSelector(parsed.getGroup(), parsed.getName(), parsed.getVersion()));
}
示例6: add
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public void add(final Class<? extends FilterReader> filterType, final Map<String, ?> properties) {
transformers.add(new Transformer<Reader, Reader>() {
public Reader transform(Reader original) {
try {
Constructor<? extends FilterReader> constructor = filterType.getConstructor(Reader.class);
FilterReader result = constructor.newInstance(original);
if (properties != null) {
ConfigureUtil.configureByMap(properties, result);
}
return result;
} catch (Throwable th) {
throw new InvalidUserDataException("Error - Invalid filter specification for " + filterType.getName(), th);
}
}
});
}
示例7: validateParentMutation
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
private void validateParentMutation(MutationType type) {
// Strategy changes in a parent configuration do not affect this configuration, or any of its children, in any way
if (type == MutationType.STRATEGY) {
return;
}
if (resolvedState == ARTIFACTS_RESOLVED) {
throw new InvalidUserDataException(String.format("Cannot change %s of parent of %s after it has been resolved", type, getDisplayName()));
} else if (resolvedState == GRAPH_RESOLVED) {
if (type == MutationType.DEPENDENCIES) {
throw new InvalidUserDataException(String.format("Cannot change %s of parent of %s after task dependencies have been resolved", type, getDisplayName()));
}
}
markAsModifiedAndNotifyChildren(type);
}
示例8: validateMutation
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public void validateMutation(MutationType type) {
if (resolvedState == ARTIFACTS_RESOLVED) {
// The public result for the configuration has been calculated.
// It is an error to change anything that would change the dependencies or artifacts
throw new InvalidUserDataException(String.format("Cannot change %s of %s after it has been resolved.", type, getDisplayName()));
} else if (resolvedState == GRAPH_RESOLVED) {
// The task dependencies for the configuration have been calculated using Configuration.getBuildDependencies().
throw new InvalidUserDataException(String.format("Cannot change %s of %s after task dependencies have been resolved", type, getDisplayName()));
} else if (observedState == GRAPH_RESOLVED || observedState == ARTIFACTS_RESOLVED) {
// The configuration has been used in a resolution, and it is an error for build logic to change any dependencies,
// exclude rules or parent configurations (values that will affect the resolved graph).
if (type != MutationType.STRATEGY) {
String extraMessage = insideBeforeResolve ? " Use 'defaultDependencies' instead of 'beforeResolve' to specify default dependencies for a configuration." : "";
throw new InvalidUserDataException(String.format("Cannot change %s of %s after it has been included in dependency resolution.%s", type, getDisplayName(), extraMessage));
}
}
markAsModifiedAndNotifyChildren(type);
}
示例9: doGetSrcDirTrees
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
private Set<DirectoryTree> doGetSrcDirTrees() {
Set<DirectoryTree> result = new LinkedHashSet<DirectoryTree>();
for (Object path : source) {
if (path instanceof SourceDirectorySet) {
SourceDirectorySet nested = (SourceDirectorySet) path;
result.addAll(nested.getSrcDirTrees());
} else {
for (File srcDir : fileResolver.resolveFiles(path)) {
if (srcDir.exists() && !srcDir.isDirectory()) {
throw new InvalidUserDataException(String.format("Source directory '%s' is not a directory.", srcDir));
}
result.add(directoryFileTreeFactory.create(srcDir, patterns));
}
}
}
return result;
}
示例10: getHeapSizeMb
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
private int getHeapSizeMb(String heapSize) {
if (heapSize == null) {
return -1; // unspecified
}
String normalized = heapSize.trim().toLowerCase();
try {
if (normalized.endsWith("m")) {
return Integer.parseInt(normalized.substring(0, normalized.length() - 1));
}
if (normalized.endsWith("g")) {
return Integer.parseInt(normalized.substring(0, normalized.length() - 1)) * 1024;
}
} catch (NumberFormatException e) {
throw new InvalidUserDataException("Cannot parse heap size: " + heapSize, e);
}
throw new InvalidUserDataException("Cannot parse heap size: " + heapSize);
}
示例11: parseNotation
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public NormalizedTimeUnit parseNotation(CharSequence notation, int value) {
String candidate = notation.toString().toUpperCase();
//jdk5 does not have days, hours or minutes, normalizing to millis
if (candidate.equals("DAYS")) {
return millis(value * 24 * 60 * 60 * 1000);
} else if (candidate.equals("HOURS")) {
return millis(value * 60 * 60 * 1000);
} else if (candidate.equals("MINUTES")) {
return millis(value * 60 * 1000);
}
try {
return new NormalizedTimeUnit(value, TimeUnit.valueOf(candidate));
} catch (Exception e) {
throw new InvalidUserDataException("Unable to parse provided TimeUnit: " + notation, e);
}
}
示例12: getTasksByName
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public Set<Task> getTasksByName(final String name, boolean recursive) {
if (!isTrue(name)) {
throw new InvalidUserDataException("Name is not specified!");
}
final Set<Task> foundTasks = new HashSet<Task>();
Action<Project> action = new Action<Project>() {
public void execute(Project project) {
// Don't force evaluation of rules here, let the task container do what it needs to
((ProjectInternal) project).evaluate();
Task task = project.getTasks().findByName(name);
if (task != null) {
foundTasks.add(task);
}
}
};
if (recursive) {
allprojects(action);
} else {
action.execute(this);
}
return foundTasks;
}
示例13: create
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
@Override
public <S extends TaskInternal> S create(String name, final Class<S> type) {
if (!Task.class.isAssignableFrom(type)) {
throw new InvalidUserDataException(String.format(
"Cannot create task of type '%s' as it does not implement the Task interface.",
type.getSimpleName()));
}
final Class<? extends Task> generatedType;
if (type.isAssignableFrom(DefaultTask.class)) {
generatedType = generator.generate(DefaultTask.class);
} else {
generatedType = generator.generate(type);
}
return type.cast(AbstractTask.injectIntoNewInstance(project, name, type, new Callable<Task>() {
public Task call() throws Exception {
try {
return instantiator.newInstance(generatedType);
} catch (ObjectInstantiationException e) {
throw new TaskInstantiationException(String.format("Could not create task of type '%s'.", type.getSimpleName()),
e.getCause());
}
}
}));
}
示例14: findByPath
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public Task findByPath(String path) {
if (!GUtil.isTrue(path)) {
throw new InvalidUserDataException("A path must be specified!");
}
if (!path.contains(Project.PATH_SEPARATOR)) {
return findByName(path);
}
String projectPath = StringUtils.substringBeforeLast(path, Project.PATH_SEPARATOR);
ProjectInternal project = this.project.findProject(!GUtil.isTrue(projectPath) ? Project.PATH_SEPARATOR : projectPath);
if (project == null) {
return null;
}
projectAccessListener.beforeRequestingTaskByPath(project);
return project.getTasks().findByName(StringUtils.substringAfterLast(path, Project.PATH_SEPARATOR));
}
示例15: execute
import org.gradle.api.InvalidUserDataException; //导入依赖的package包/类
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
List<String> messages = new ArrayList<String>();
for (TaskValidator validator : task.getValidators()) {
validator.validate(task, messages);
}
if (!messages.isEmpty()) {
List<InvalidUserDataException> causes = new ArrayList<InvalidUserDataException>();
messages = messages.subList(0, Math.min(5, messages.size()));
for (String message : messages) {
causes.add(new InvalidUserDataException(message));
}
String errorMessage;
if (messages.size() == 1) {
errorMessage = String.format("A problem was found with the configuration of %s.", task);
} else {
errorMessage = String.format("Some problems were found with the configuration of %s.", task);
}
state.setOutcome(new TaskValidationException(errorMessage, causes));
return;
}
executer.execute(task, state, context);
}