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

The following examples show how to use org.gradle.api.Project#getPath() . 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: 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 3
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 4
Source File: SdkUtil.java    From firebase-android-sdk with Apache License 2.0 5 votes vote down vote up
public static File getAndroidJar(Project project) {
  LibraryExtension android = project.getExtensions().findByType(LibraryExtension.class);
  if (android == null) {
    throw new GradleException("Project " + project.getPath() + " is not an android library.");
  }
  return new File(
      getSdkDir(project),
      String.format("/platforms/%s/android.jar", android.getCompileSdkVersion()));
}
 
Example 5
Source File: TextReportRenderer.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
protected String createHeader(Project project) {
    String header;
    if (project.getRootProject() == project) {
        header = "Root project";
    } else {
        header = "Project " + project.getPath();
    }
    if (GUtil.isTrue(project.getDescription())) {
        header = header + " - " + project.getDescription();
    }
    return header;
}
 
Example 6
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 7
Source File: ProjectUtil.java    From shipkit with MIT License 5 votes vote down vote up
public static void requireRootProject(final Project project, final Class<?> clazz, final String explanation) {
    if (project.getParent() != null) {
        throw new GradleException("Plugin '" + clazz.getSimpleName() + "' is intended to be applied only root project.\n" +
            (explanation != null ? explanation + "\n" : "" ) +
            "Please apply this plugin to the root project instead of '" + project.getPath() + "'.");
    }
}
 
Example 8
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 9
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 10
Source File: AndroidExtension.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public AndroidExtension(Project project, ToolingModelBuilderRegistry registry) {
    this.project = project;

    this.extraModelInfo = new ExtraModelInfo(new ProjectOptions(project), project.getLogger());

    this.signingConfig = project.getExtensions().create("signingConfig", SigningConfig.class, "signing");
    this.packagingOptions = project.getExtensions().create("packagingOptions", PackagingOptions.class);
    this.dexOptions = project.getExtensions().create("dexOptions", DexOptions.class, extraModelInfo);

    try {
        this.buildCache = FileCache.getInstanceWithMultiProcessLocking(new File(AndroidLocation.getFolder(), "build-cache"));
    } catch (AndroidLocation.AndroidLocationException e) {
        throw new RuntimeException(e);
    }

    LoggerWrapper loggerWrapper = new LoggerWrapper(project.getLogger());

    this.sdkHandler = new SdkHandler(project, loggerWrapper);
    this.androidBuilder = new AndroidBuilder(
            project == project.getRootProject() ? project.getName() : project.getPath(),
            "JavaFX Mobile",
            new GradleProcessExecutor(project),
            new GradleJavaProcessExecutor(project),
            extraModelInfo,
            loggerWrapper,
            false);

    this.androidTaskRegistry = new AndroidTaskRegistry();
    this.taskFactory = new TaskContainerAdaptor(project.getTasks());

    installDirectory = new File(project.getBuildDir(), "javafxports/android");
    project.getLogger().info("Android install directory: " + installDirectory);

    temporaryDirectory = new File(project.getBuildDir(), "javafxports/tmp/android");
    project.getLogger().info("Android temporary output directory: " + temporaryDirectory);

    resourcesDirectory = new File(temporaryDirectory, "resources");
    resourcesDirectory.mkdirs();
    project.getLogger().info("Resources directory: " + resourcesDirectory);

    multidexOutputDirectory = new File(temporaryDirectory, "multi-dex");
    multidexOutputDirectory.mkdirs();
    project.getLogger().info("Multi-dex output directory: " + multidexOutputDirectory);

    dexOutputDirectory = new File(temporaryDirectory, "dex");
    dexOutputDirectory.mkdirs();
    project.getLogger().info("Dex output directory: " + dexOutputDirectory);
}