Java Code Examples for org.gradle.api.Project#getName()

The following examples show how to use org.gradle.api.Project#getName() . 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: ProjectDependencyPublicationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}
 
Example 2
Source File: SarosEclipsePlugin.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private void createPluginVersionChangeTask(Project p, SarosEclipseExtension e) {
  String qualifier = e.getPluginVersionQualifier();
  if (qualifier == null || qualifier.trim().isEmpty()) return;

  p.getTasks()
      .register(
          PLUGIN_VERSION_CHANGE_TASK_NAME,
          (task) -> {
            task.getInputs().property("versionQualifier", qualifier);

            task.doLast(
                (t) -> {
                  methodRequiresManifest("set version qualifier", e);
                  new OsgiBundleVersionConfigurator(e.getManifest()).addQualifier(qualifier);
                });
          });

  Task jarTask = p.getTasks().findByPath("jar");
  if (jarTask == null)
    throw new GradleException("Unable to find jar task in project " + p.getName());
  jarTask.dependsOn(PLUGIN_VERSION_CHANGE_TASK_NAME);
}
 
Example 3
Source File: AppEngineStandardPlugin.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void apply(Project project) {
  this.project = project;
  appengineExtension =
      project.getExtensions().create("appengine", AppEngineStandardExtension.class);
  appengineExtension.createSubExtensions(project);

  appEngineCorePluginConfiguration = new AppEngineCorePluginConfiguration();
  appEngineCorePluginConfiguration.configureCoreProperties(
      project, appengineExtension, APP_ENGINE_STANDARD_TASK_GROUP, true);

  explodedWarDir = new File(project.getBuildDir(), "exploded-" + project.getName());

  configureExtensions();

  createExplodedWarTask();
  createStageTask();
  createRunTasks();
}
 
Example 4
Source File: BasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check the sub-projects structure :
 * So far, checks that 2 modules do not have the same identification (group+name).
 */
private void checkModulesForErrors() {
    Project rootProject = project.getRootProject();
    Map<String, Project> subProjectsById = new HashMap<String, Project>();
    for (Project subProject : rootProject.getAllprojects()) {
        String id = subProject.getGroup().toString() + ":" + subProject.getName();
        if (subProjectsById.containsKey(id)) {
            String message = String.format(
                    "Your project contains 2 or more modules with the same " +
                            "identification %1$s\n" +
                            "at \"%2$s\" and \"%3$s\".\n" +
                            "You must use different identification (either name or group) for " +
                            "each modules.",
                    id,
                    subProjectsById.get(id).getPath(),
                    subProject.getPath());
            throw new StopExecutionException(message);
        } else {
            subProjectsById.put(id, subProject);
        }
    }
}
 
Example 5
Source File: ProjectDependencyPublicationResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}
 
Example 6
Source File: ProjectDependencyPublicationResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}
 
Example 7
Source File: ProjectDependencyPublicationResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public ModuleVersionIdentifier resolve(ProjectDependency dependency) {
    Project dependencyProject = dependency.getDependencyProject();
    ((ProjectInternal) dependencyProject).evaluate();

    PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class);

    if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) {
        // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name
        return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion());
    }

    // See if all publications have the same identifier
    Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class);
    Iterator<? extends PublicationInternal> iterator = publications.iterator();
    ModuleVersionIdentifier candidate = iterator.next().getCoordinates();
    while (iterator.hasNext()) {
        ModuleVersionIdentifier alternative = iterator.next().getCoordinates();
        if (!candidate.equals(alternative)) {
            throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications.");
        }
    }
    return candidate;

}
 
Example 8
Source File: ProjectConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds all sub projects of the specified GradleProject.
 *
 * @param parentProject the source parent project. Where we get the sub projects from.
 * @param parentProjectView the destination of the sub projects from parentProject.
 */
private void addSubProjects(Project parentProject, ProjectView parentProjectView) {
    Collection<Project> subProjects = parentProject.getChildProjects().values();
    for (Project subProject : subProjects) {
        ProjectView projectView = new ProjectView(parentProjectView, subProject.getName(), subProject.getBuildFile(), subProject.getDescription());
        projectMap.put(subProject, projectView);

        addTasks(subProject, projectView);

        projectView.sortSubProjectsAndTasks();

        addSubProjects(subProject, projectView);
    }
}
 
Example 9
Source File: ProjectOutcomesModelBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private DefaultProjectOutcomes buildProjectOutput(Project project, ProjectOutcomes parent) {
    DefaultProjectOutcomes projectOutput = new DefaultProjectOutcomes(project.getName(), project.getPath(),
            project.getDescription(), project.getProjectDir(), getFileOutcomes(project), parent);
    for (Project child : project.getChildProjects().values()) {
        projectOutput.addChild(buildProjectOutput(child, projectOutput));
    }
    return projectOutput;
}
 
Example 10
Source File: ModuleDependencyBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ModuleDependency create(Project project, String scope) {
    if (project.getPlugins().hasPlugin(IdeaPlugin.class)) {
        return new ModuleDependency(((IdeaModel) project.getExtensions().getByName("idea")).getModule().getName(), scope);
    } else {
        return new ModuleDependency(project.getName(), scope);
    }
}
 
Example 11
Source File: ProjectConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds all sub projects of the specified GradleProject.
 *
 * @param parentProject the source parent project. Where we get the sub projects from.
 * @param parentProjectView the destination of the sub projects from parentProject.
 */
private void addSubProjects(Project parentProject, ProjectView parentProjectView) {
    Collection<Project> subProjects = parentProject.getChildProjects().values();
    for (Project subProject : subProjects) {
        ProjectView projectView = new ProjectView(parentProjectView, subProject.getName(), subProject.getBuildFile(), subProject.getDescription());
        projectMap.put(subProject, projectView);

        addTasks(subProject, projectView);

        projectView.sortSubProjectsAndTasks();

        addSubProjects(subProject, projectView);
    }
}
 
Example 12
Source File: BaseComponentModelPlugin.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Model(ANDROID_BUILDER)
public AndroidBuilder createAndroidBuilder(Project project, ExtraModelInfo extraModelInfo) {
    String creator = "Android Gradle";
    ILogger logger = new LoggerWrapper(project.getLogger());

    return new AndroidBuilder(project.equals(project.getRootProject()) ? project.getName()
            : project.getPath(), creator, new GradleProcessExecutor(project),
            new GradleJavaProcessExecutor(project),
            extraModelInfo, logger, project.getLogger().isEnabled(LogLevel.INFO));

}
 
Example 13
Source File: ProjectOutcomesModelBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private DefaultProjectOutcomes buildProjectOutput(Project project, ProjectOutcomes parent) {
    DefaultProjectOutcomes projectOutput = new DefaultProjectOutcomes(project.getName(), project.getPath(),
            project.getDescription(), project.getProjectDir(), getFileOutcomes(project), parent);
    for (Project child : project.getChildProjects().values()) {
        projectOutput.addChild(buildProjectOutput(child, projectOutput));
    }
    return projectOutput;
}
 
Example 14
Source File: ModuleDependencyBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ModuleDependency create(Project project, String scope) {
    if (project.getPlugins().hasPlugin(IdeaPlugin.class)) {
        return new ModuleDependency(((IdeaModel) project.getExtensions().getByName("idea")).getModule().getName(), scope);
    } else {
        return new ModuleDependency(project.getName(), scope);
    }
}
 
Example 15
Source File: ProjectOutcomesModelBuilder.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private DefaultProjectOutcomes buildProjectOutput(Project project, ProjectOutcomes parent) {
    DefaultProjectOutcomes projectOutput = new DefaultProjectOutcomes(project.getName(), project.getPath(),
            project.getDescription(), project.getProjectDir(), getFileOutcomes(project), parent);
    for (Project child : project.getChildProjects().values()) {
        projectOutput.addChild(buildProjectOutput(child, projectOutput));
    }
    return projectOutput;
}
 
Example 16
Source File: ProjectConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds all sub projects of the specified GradleProject.
 *
 * @param parentProject the source parent project. Where we get the sub projects from.
 * @param parentProjectView the destination of the sub projects from parentProject.
 */
private void addSubProjects(Project parentProject, ProjectView parentProjectView) {
    Collection<Project> subProjects = parentProject.getChildProjects().values();
    for (Project subProject : subProjects) {
        ProjectView projectView = new ProjectView(parentProjectView, subProject.getName(), subProject.getBuildFile(), subProject.getDescription());

        addTasks(subProject, projectView);

        projectView.sortSubProjectsAndTasks();

        addSubProjects(subProject, projectView);
    }
}
 
Example 17
Source File: ProjectConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Adds all sub projects of the specified GradleProject.
 *
 * @param parentProject the source parent project. Where we get the sub projects from.
 * @param parentProjectView the destination of the sub projects from parentProject.
 */
private void addSubProjects(Project parentProject, ProjectView parentProjectView) {
    Collection<Project> subProjects = parentProject.getChildProjects().values();
    for (Project subProject : subProjects) {
        ProjectView projectView = new ProjectView(parentProjectView, subProject.getName(), subProject.getBuildFile(), subProject.getDescription());

        addTasks(subProject, projectView);

        projectView.sortSubProjectsAndTasks();

        addSubProjects(subProject, projectView);
    }
}
 
Example 18
Source File: RunExtensionTest.java    From app-gradle-plugin with Apache License 2.0 4 votes vote down vote up
private File getExplodedAppDirectory(Project project) {
  return new File(project.getBuildDir(), "exploded-" + project.getName());
}
 
Example 19
Source File: ProjectConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * This adds the specified poject as a root level projects. It then adds all tasks and recursively adds all sub projects.
 *
 * @param rootLevelProject a root level project.
 */
public void addRootLevelProject(Project rootLevelProject) {
    ProjectView rootLevelProjectView = new ProjectView(null, rootLevelProject.getName(), rootLevelProject.getBuildFile(), rootLevelProject.getDescription());
    projectMap.put(rootLevelProject, rootLevelProjectView);

    rootLevelResultingProjects.add(rootLevelProjectView);

    addSubProjects(rootLevelProject, rootLevelProjectView);

    addTasks(rootLevelProject, rootLevelProjectView);

    rootLevelProjectView.sortSubProjectsAndTasks();
}
 
Example 20
Source File: ProjectConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * This adds the specified poject as a root level projects. It then adds all tasks and recursively adds all sub projects.
 *
 * @param rootLevelProject a root level project.
 */
public void addRootLevelProject(Project rootLevelProject) {
    ProjectView rootLevelProjectView = new ProjectView(null, rootLevelProject.getName(), rootLevelProject.getBuildFile(), rootLevelProject.getDescription());
    projectMap.put(rootLevelProject, rootLevelProjectView);

    rootLevelResultingProjects.add(rootLevelProjectView);

    addSubProjects(rootLevelProject, rootLevelProjectView);

    addTasks(rootLevelProject, rootLevelProjectView);

    rootLevelProjectView.sortSubProjectsAndTasks();
}