use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class DependenciesAwareVersionCatalogBuilder method copyDependencyVersion.
private static void copyDependencyVersion(Dependency dependency, String group, String name, MutableVersionConstraint v) {
if (dependency instanceof ExternalModuleDependency) {
VersionConstraint vc = ((ExternalModuleDependency) dependency).getVersionConstraint();
copyConstraint(vc, v);
} else {
String version = dependency.getVersion();
if (version == null || version.isEmpty()) {
throw new InvalidUserDataException("Version for dependency " + group + ":" + name + " must not be empty");
}
v.require(version);
}
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class PublishToIvyRepository method publish.
@TaskAction
public void publish() {
IvyPublicationInternal publicationInternal = getPublicationInternal();
if (publicationInternal == null) {
throw new InvalidUserDataException("The 'publication' property is required");
}
IvyArtifactRepository repository = getRepository();
if (repository == null) {
throw new InvalidUserDataException("The 'repository' property is required");
}
getDuplicatePublicationTracker().checkCanPublish(publicationInternal, repository.getUrl(), repository.getName());
doPublish(publicationInternal, repository);
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class SigningExtension method addSignatureSpecConventions.
/**
* Adds conventions to the given spec, using this settings object's default signatory and signature type as the default signatory and signature type for the spec.
*/
protected void addSignatureSpecConventions(SignatureSpec spec) {
if (!(spec instanceof IConventionAware)) {
throw new InvalidUserDataException("Cannot add conventions to signature spec \'" + String.valueOf(spec) + "\' as it is not convention aware");
}
ConventionMapping conventionMapping = ((IConventionAware) spec).getConventionMapping();
conventionMapping.map("signatory", new Callable<Signatory>() {
@Override
public Signatory call() {
return getSignatory();
}
});
conventionMapping.map("signatureType", new Callable<SignatureType>() {
@Override
public SignatureType call() {
return getSignatureType();
}
});
conventionMapping.map("required", new Callable<Boolean>() {
@Override
public Boolean call() {
return isRequired();
}
});
}
use of org.gradle.api.InvalidUserDataException in project cayenne by apache.
the class CgenTask method getDestDirFile.
@OutputDirectory
protected File getDestDirFile() {
final Reference<File> javaSourceDir = new Reference<>(null);
if (destDir != null) {
javaSourceDir.set(destDir);
} else if (destDirName != null) {
javaSourceDir.set(getProject().file(destDirName));
} else {
getProject().getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
@Override
public void execute(final JavaPlugin plugin) {
SourceSetContainer sourceSets = (SourceSetContainer) getProject().getProperties().get("sourceSets");
Set<File> sourceDirs = sourceSets.getByName("main").getJava().getSrcDirs();
if (sourceDirs != null && !sourceDirs.isEmpty()) {
// find java directory, if there is no such dir, take first
for (File dir : sourceDirs) {
if (dir.getName().endsWith("java")) {
javaSourceDir.set(dir);
break;
}
}
if (javaSourceDir.get() == null) {
javaSourceDir.set(sourceDirs.iterator().next());
}
}
}
});
}
if (javaSourceDir.get() == null) {
throw new InvalidUserDataException("cgen.destDir is not set and there is no Java source sets found.");
}
if (!javaSourceDir.get().exists()) {
javaSourceDir.get().mkdirs();
}
return javaSourceDir.get();
}
use of org.gradle.api.InvalidUserDataException in project gradle by gradle.
the class AnnotationProcessorDiscoveringCompiler method getEffectiveAnnotationProcessors.
/**
* Scans the processor path for processor declarations. Filters them if the explicit <code>-processor</code> argument is given.
* Treats explicit processors that didn't have a matching declaration on the path as non-incremental.
*/
private Set<AnnotationProcessorDeclaration> getEffectiveAnnotationProcessors(JavaCompileSpec spec) {
Map<String, AnnotationProcessorDeclaration> declarations = annotationProcessorDetector.detectProcessors(spec.getAnnotationProcessorPath());
List<String> compilerArgs = spec.getCompileOptions().getCompilerArgs();
int processorIndex = compilerArgs.lastIndexOf("-processor");
if (processorIndex == -1) {
return Sets.newLinkedHashSet(declarations.values());
}
if (processorIndex == compilerArgs.size() - 1) {
throw new InvalidUserDataException("No processor specified for compiler argument -processor in requested compiler args: " + Joiner.on(" ").join(compilerArgs));
}
Collection<String> explicitProcessors = Splitter.on(',').splitToList(compilerArgs.get(processorIndex + 1));
Set<AnnotationProcessorDeclaration> effectiveProcessors = Sets.newLinkedHashSet();
for (String explicitProcessor : explicitProcessors) {
AnnotationProcessorDeclaration declaration = declarations.get(explicitProcessor);
if (declaration != null) {
effectiveProcessors.add(declaration);
} else {
effectiveProcessors.add(new AnnotationProcessorDeclaration(explicitProcessor, IncrementalAnnotationProcessorType.UNKNOWN));
}
}
return effectiveProcessors;
}
Aggregations