use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class AnnotationProcessorPathFactory method getProcessorPathFromCompilerArguments.
private FileCollection getProcessorPathFromCompilerArguments(final CompileOptions compileOptions) {
final FileCollection annotationProcessorPath = compileOptions.getAnnotationProcessorPath();
List<String> compilerArgs = compileOptions.getAllCompilerArgs();
int pos = compilerArgs.indexOf("-processorpath");
if (pos < 0) {
return null;
}
if (pos == compilerArgs.size() - 1) {
throw new InvalidUserDataException("No path provided for compiler argument -processorpath in requested compiler args: " + Joiner.on(" ").join(compilerArgs));
}
final String processorpath = compilerArgs.get(pos + 1);
if (annotationProcessorPath == null) {
return fileCollectionFactory.fixed("annotation processor path", extractProcessorPath(processorpath));
}
return fileCollectionFactory.create(new AbstractTaskDependency() {
@Override
public void visitDependencies(TaskDependencyResolveContext context) {
context.add(annotationProcessorPath);
}
}, new MinimalFileSet() {
@Override
public Set<File> getFiles() {
if (!annotationProcessorPath.isEmpty()) {
return annotationProcessorPath.getFiles();
}
return extractProcessorPath(processorpath);
}
@Override
public final String getDisplayName() {
return "annotation processor path";
}
});
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultIvyPublication method from.
public void from(SoftwareComponent component) {
if (this.component != null) {
throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name));
}
this.component = (SoftwareComponentInternal) component;
configurations.maybeCreate("default");
Set<PublishArtifact> seenArtifacts = Sets.newHashSet();
Set<ModuleDependency> seenDependencies = Sets.newHashSet();
for (UsageContext usageContext : getSortedUsageContexts()) {
Usage usage = usageContext.getUsage();
String conf = mapUsage(usage);
configurations.maybeCreate(conf);
configurations.getByName("default").extend(conf);
for (PublishArtifact publishArtifact : usageContext.getArtifacts()) {
if (!seenArtifacts.contains(publishArtifact)) {
seenArtifacts.add(publishArtifact);
artifact(publishArtifact).setConf(conf);
}
}
for (ModuleDependency dependency : usageContext.getDependencies()) {
if (seenDependencies.add(dependency)) {
// TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id.
String confMapping = String.format("%s->%s", conf, dependency.getTargetConfiguration() == null ? Dependency.DEFAULT_CONFIGURATION : dependency.getTargetConfiguration());
if (dependency instanceof ProjectDependency) {
addProjectDependency((ProjectDependency) dependency, confMapping);
} else {
addExternalDependency((ExternalDependency) dependency, confMapping);
}
}
}
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DefaultMavenPublication method from.
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;
Set<ArtifactKey> seenArtifacts = Sets.newHashSet();
Set<ModuleDependency> seenDependencies = Sets.newHashSet();
Set<DependencyConstraint> seenConstraints = Sets.newHashSet();
for (UsageContext usageContext : getSortedUsageContexts()) {
// TODO Need a smarter way to map usage to artifact classifier
for (PublishArtifact publishArtifact : usageContext.getArtifacts()) {
ArtifactKey key = new ArtifactKey(publishArtifact.getFile(), publishArtifact.getClassifier(), publishArtifact.getExtension());
if (seenArtifacts.add(key)) {
artifact(publishArtifact);
}
}
Set<MavenDependencyInternal> dependencies = dependenciesFor(usageContext.getUsage());
for (ModuleDependency dependency : usageContext.getDependencies()) {
if (seenDependencies.add(dependency)) {
if (dependency instanceof ProjectDependency) {
addProjectDependency((ProjectDependency) dependency, dependencies);
} else {
addModuleDependency(dependency, dependencies);
}
}
}
Set<MavenDependency> dependencyConstraints = dependencyConstraintsFor(usageContext.getUsage());
for (DependencyConstraint dependency : usageContext.getDependencyConstraints()) {
if (seenConstraints.add(dependency) && !dependency.getVersionConstraint().getPreferredVersion().isEmpty()) {
addDependencyConstraint(dependency, dependencyConstraints);
}
}
}
}
use of org.gradle.api.InvalidUserDataException in project spring-boot by spring-projects.
the class InteractiveUpgradeResolver method alignedVersionOption.
private VersionOption alignedVersionOption(Library library, Map<String, Library> libraries) {
VersionAlignment versionAlignment = library.getVersion().getVersionAlignment();
Library alignmentLibrary = libraries.get(versionAlignment.getLibraryName());
DependencyVersions dependencyVersions = alignmentLibrary.getDependencyVersions();
if (dependencyVersions == null) {
throw new InvalidUserDataException("Cannot align with library '" + versionAlignment.getLibraryName() + "' as it does not define any dependency versions");
}
if (!dependencyVersions.available()) {
return null;
}
Set<String> versions = new HashSet<>();
for (Group group : library.getGroups()) {
for (Module module : group.getModules()) {
String version = dependencyVersions.getVersion(group.getId(), module.getName());
if (version != null) {
versions.add(version);
}
}
}
if (versions.isEmpty()) {
throw new InvalidUserDataException("Cannot align with library '" + versionAlignment.getLibraryName() + "' as its dependency versions do not include any of this library's modules");
}
if (versions.size() > 1) {
throw new InvalidUserDataException("Cannot align with library '" + versionAlignment.getLibraryName() + "' as it uses multiple different versions of this library's modules");
}
DependencyVersion version = DependencyVersion.parse(versions.iterator().next());
return library.getVersion().getVersion().equals(version) ? null : new AlignedVersionOption(version, alignmentLibrary);
}
use of org.gradle.api.InvalidUserDataException in project spring-boot by spring-projects.
the class UpgradeBom method createGitHub.
private GitHub createGitHub() {
Properties bomrProperties = new Properties();
try (Reader reader = new FileReader(new File(System.getProperty("user.home"), ".bomr.properties"))) {
bomrProperties.load(reader);
String username = bomrProperties.getProperty("bomr.github.username");
String password = bomrProperties.getProperty("bomr.github.password");
return GitHub.withCredentials(username, password);
} catch (IOException ex) {
throw new InvalidUserDataException("Failed to load .bomr.properties from user home", ex);
}
}
Aggregations