org.gradle.api.UnknownDomainObjectException Java Examples

The following examples show how to use org.gradle.api.UnknownDomainObjectException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModuleName.java    From gradle-modules-plugin with MIT License 6 votes vote down vote up
Optional<String> findModuleName(Project project) {
    SourceSet main;
    try {
        JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
        main = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    } catch (IllegalStateException | UnknownDomainObjectException e) {
        LOGGER.warn("Cannot obtain JavaPluginConvention", e);
        return Optional.empty();
    }

    Optional<Path> moduleInfoJava = main.getAllJava()
            .getSourceDirectories()
            .getFiles()
            .stream()
            .map(sourceDir -> sourceDir.toPath().resolve("module-info.java"))
            .filter(Files::exists)
            .findAny();

    String projectPath = project.getPath();
    if (moduleInfoJava.isEmpty()) {
        LOGGER.lifecycle("Project {} => no module-info.java found", projectPath);
        return Optional.empty();
    }

    return findModuleName(moduleInfoJava.get(), projectPath);
}
 
Example #2
Source File: FirebaseLibraryExtension.java    From firebase-android-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Register to be released alongside another Firebase Library project.
 *
 * <p>This will force the released version of the current project to match the one it's released
 * with.
 */
public void releaseWith(Project releaseWithProject) {
  try {
    FirebaseLibraryExtension releaseWithLibrary =
        releaseWithProject.getExtensions().getByType(FirebaseLibraryExtension.class);
    releaseWithLibrary.librariesToCoRelease.add(this);
    this.project.setVersion(releaseWithProject.getVersion());

    String latestRelease = "latestReleasedVersion";
    if (releaseWithProject.getExtensions().getExtraProperties().has(latestRelease)) {
      this.project
          .getExtensions()
          .getExtraProperties()
          .set(latestRelease, releaseWithProject.getProperties().get(latestRelease));
    }

  } catch (UnknownDomainObjectException ex) {
    throw new GradleException(
        "Library cannot be released with a project that is not a Firebase Library itself");
  }
}
 
Example #3
Source File: DefaultBinaryTasksCollection.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected <T extends Task> T findSingleTaskWithType(Class<T> type) {
    DomainObjectSet<T> tasks = withType(type);
    if (tasks.size() == 0) {
        return null;
    }
    if (tasks.size() > 1) {
        throw new UnknownDomainObjectException(String.format("Multiple tasks with type '%s' found.", type.getSimpleName()));
    }
    return tasks.iterator().next();
}
 
Example #4
Source File: ExtensionsStorage.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T> ExtensionHolder<T> getHolderByType(Class<T> type) {
    List<String> types = new LinkedList<String>();
    for (ExtensionHolder extensionHolder : extensions.values()) {
        Class<?> clazz = extensionHolder.getType();
        types.add(clazz.getSimpleName());
        if (type.isAssignableFrom(clazz)) {
            return extensionHolder;
        }
    }
    throw new UnknownDomainObjectException("Extension of type '" + type.getSimpleName() + "' does not exist. Currently registered extension types: " + types);
}
 
Example #5
Source File: ExtensionsStorage.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> T findByType(Class<T> type) {
    ExtensionHolder<T> holder;
    try {
        holder = getHolderByType(type);
    } catch (UnknownDomainObjectException e) {
        return null;
    }
    return holder.get();
}
 
Example #6
Source File: DefaultNativeBinaryTasks.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T extends Task> T findOnlyWithType(Class<T> type) {
    DomainObjectSet<T> tasks = withType(type);
    if (tasks.size() == 0) {
        return null;
    }
    if (tasks.size() > 1) {
        throw new UnknownDomainObjectException(String.format("Multiple task with type '%s' found", type.getSimpleName()));
    }
    return tasks.iterator().next();
}
 
Example #7
Source File: ExtensionsStorage.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T> ExtensionHolder<T> getHolderByType(Class<T> type) {
    List<String> types = new LinkedList<String>();
    for (ExtensionHolder extensionHolder : extensions.values()) {
        Class<?> clazz = extensionHolder.getType();
        types.add(clazz.getSimpleName());
        if (type.isAssignableFrom(clazz)) {
            return extensionHolder;
        }
    }
    throw new UnknownDomainObjectException("Extension of type '" + type.getSimpleName() + "' does not exist. Currently registered extension types: " + types);
}
 
Example #8
Source File: ExtensionsStorage.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> T findByType(Class<T> type) {
    ExtensionHolder<T> holder;
    try {
        holder = getHolderByType(type);
    } catch (UnknownDomainObjectException e) {
        return null;
    }
    return holder.get();
}
 
Example #9
Source File: DefaultBinaryTasksCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
protected <T extends Task> T findSingleTaskWithType(Class<T> type) {
    DomainObjectSet<T> tasks = withType(type);
    if (tasks.size() == 0) {
        return null;
    }
    if (tasks.size() > 1) {
        throw new UnknownDomainObjectException(String.format("Multiple tasks with type '%s' found.", type.getSimpleName()));
    }
    return tasks.iterator().next();
}
 
Example #10
Source File: GCloudPlugin.java    From gradle-plugins with Apache License 2.0 5 votes vote down vote up
public void apply(Project project) {
	GCloudExtension extension = project.getExtensions().create("gcloud", GCloudExtension.class);
	extension.initProject(project);
	extension.getCli().getBinNames().add("gsutil");
	extension.getCli().setImageName("google/cloud-sdk");
	extension.getCli().setImageTag("159.0.0");

	GCloudActivateServiceAccountTask activateServiceAccount =
			project.getTasks().create("gcloudActivateServiceAccount", GCloudActivateServiceAccountTask.class);
	GCloudGetKubernetesCredentialsTask getCredentials =
			project.getTasks().create("gcloudGetKubernetesCredentials", GCloudGetKubernetesCredentialsTask.class);
	GCloudSetProjectTask setProject = project.getTasks().create("gcloudSetProject",
			GCloudSetProjectTask.class);

	getCredentials.dependsOn(setProject);


	extension.getGke().setKubeDir(new File(project.getRootProject().getProjectDir(), "build/.kube"));

	CliExecExtension cliExec = project.getExtensions().getByType(CliExecExtension.class);
	cliExec.register("gcloud", extension.getCli());
	cliExec.register("gsutil", extension.getCli());

	project.afterEvaluate(project1 -> {
		Cli cli = extension.getCli();

		// integrate with Kubernetes if available
		try {
			ClientExtensionBase kubectl = (ClientExtensionBase) project.getExtensions().getByName("kubectl");
			Cli kubectlCli = kubectl.getCli();
			kubectlCli.setImageName(cli.getImageName());
			kubectlCli.setImageTag(cli.getImageTag());
		} catch (UnknownDomainObjectException e) {
		}
	});
}
 
Example #11
Source File: ExtensionsStorage.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T> ExtensionHolder<T> getHolderByType(Class<T> type) {
    List<String> types = new LinkedList<String>();
    for (ExtensionHolder extensionHolder : extensions.values()) {
        Class<?> clazz = extensionHolder.getType();
        types.add(clazz.getSimpleName());
        if (type.isAssignableFrom(clazz)) {
            return extensionHolder;
        }
    }
    throw new UnknownDomainObjectException("Extension of type '" + type.getSimpleName() + "' does not exist. Currently registered extension types: " + types);
}
 
Example #12
Source File: ExtensionsStorage.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> T findByType(Class<T> type) {
    ExtensionHolder<T> holder;
    try {
        holder = getHolderByType(type);
    } catch (UnknownDomainObjectException e) {
        return null;
    }
    return holder.get();
}
 
Example #13
Source File: DefaultNativeBinaryTasks.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T extends Task> T findOnlyWithType(Class<T> type) {
    DomainObjectSet<T> tasks = withType(type);
    if (tasks.size() == 0) {
        return null;
    }
    if (tasks.size() > 1) {
        throw new UnknownDomainObjectException(String.format("Multiple task with type '%s' found", type.getSimpleName()));
    }
    return tasks.iterator().next();
}
 
Example #14
Source File: ExtensionsStorage.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public <T> T findByType(Class<T> type) {
    ExtensionHolder<T> holder;
    try {
        holder = getHolderByType(type);
    } catch (UnknownDomainObjectException e) {
        return null;
    }
    return holder.get();
}
 
Example #15
Source File: ExtensionsStorage.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T> ExtensionHolder<T> getHolderByType(Class<T> type) {
    List<String> types = new LinkedList<String>();
    for (ExtensionHolder extensionHolder : extensions.values()) {
        Class<?> clazz = extensionHolder.getType();
        types.add(clazz.getSimpleName());
        if (type.isAssignableFrom(clazz)) {
            return extensionHolder;
        }
    }
    throw new UnknownDomainObjectException("Extension of type '" + type.getSimpleName() + "' does not exist. Currently registered extension types: " + types);
}
 
Example #16
Source File: DefaultArtifactRepositoryContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownRepositoryException(String.format("Repository with name '%s' not found.", name));
}
 
Example #17
Source File: ExtensionsStorage.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Object getByName(String name) {
    if (!hasExtension(name)) {
        throw new UnknownDomainObjectException("Extension with name '" + name + "' does not exist. Currently registered extension names: " + extensions.keySet());
    }
    return findByName(name);
}
 
Example #18
Source File: DefaultConfigurationContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownConfigurationException(String.format("Configuration with name '%s' not found.", name));
}
 
Example #19
Source File: DefaultTaskCollection.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownTaskException(String.format("Task with name '%s' not found in %s.", name, project));
}
 
Example #20
Source File: DefaultArtifactRepositoryContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownRepositoryException(String.format("Repository with name '%s' not found.", name));
}
 
Example #21
Source File: DefaultTaskCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownTaskException(String.format("Task with name '%s' not found in %s.", name, project));
}
 
Example #22
Source File: DefaultConfigurationContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownConfigurationException(String.format("Configuration with name '%s' not found.", name));
}
 
Example #23
Source File: DefaultArtifactRepositoryContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownRepositoryException(String.format("Repository with name '%s' not found.", name));
}
 
Example #24
Source File: ExtensionsStorage.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Object getByName(String name) {
    if (!hasExtension(name)) {
        throw new UnknownDomainObjectException("Extension with name '" + name + "' does not exist. Currently registered extension names: " + extensions.keySet());
    }
    return findByName(name);
}
 
Example #25
Source File: DefaultArtifactRepositoryContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownRepositoryException(String.format("Repository with name '%s' not found.", name));
}
 
Example #26
Source File: DefaultTaskCollection.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownTaskException(String.format("Task with name '%s' not found in %s.", name, project));
}
 
Example #27
Source File: DefaultConfigurationContainer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownConfigurationException(String.format("Configuration with name '%s' not found.", name));
}
 
Example #28
Source File: ExtensionsStorage.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Object getByName(String name) {
    if (!hasExtension(name)) {
        throw new UnknownDomainObjectException("Extension with name '" + name + "' does not exist. Currently registered extension names: " + extensions.keySet());
    }
    return findByName(name);
}
 
Example #29
Source File: ExtensionsStorage.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public Object getByName(String name) {
    if (!hasExtension(name)) {
        throw new UnknownDomainObjectException("Extension with name '" + name + "' does not exist. Currently registered extension names: " + extensions.keySet());
    }
    return findByName(name);
}
 
Example #30
Source File: DefaultConfigurationContainer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected UnknownDomainObjectException createNotFoundException(String name) {
    return new UnknownConfigurationException(String.format("Configuration with name '%s' not found.", name));
}