private void _forceProjectHierarchyEvaluation(Project project) {
    GradleInternal gradleInternal = (GradleInternal) project.getGradle();

    ServiceRegistry serviceRegistry = gradleInternal.getServices();

    ProjectConfigurer projectConfigurer = serviceRegistry.get(ProjectConfigurer.class);

    projectConfigurer.configureHierarchy((ProjectInternal) project);
  }
  @Override
  public void apply(Project project) {
    String appDescription = null;
    String appTitle = null;
    String appVersion = null;

    File appBndFile = project.file("app.bnd");

    if (appBndFile.exists()) {
      Properties properties = GUtil.loadProperties(appBndFile);

      appDescription = properties.getProperty("Liferay-Releng-App-Description");
    }

    Properties appProperties = null;

    Project privateProject = project.findProject(":private" + project.getPath());

    if (privateProject != null) {
      appProperties = _getAppProperties(privateProject);
    }

    if (appProperties == null) {
      appProperties = _getAppProperties(project);
    }

    if (appProperties != null) {
      appTitle = appProperties.getProperty("app.marketplace.title");
      appVersion = appProperties.getProperty("app.marketplace.version");
    }

    _applyPlugins(project);

    LiferayOSGiDefaultsPlugin.configureRepositories(project);

    _configureAppJavadocBuilder(project, privateProject);
    _configureAppTLDDocBuilder(project, privateProject);
    _configureProject(project, appDescription, appVersion);
    _configureTaskAppJavadoc(project, appTitle, appVersion);

    if (privateProject != null) {
      Gradle gradle = project.getGradle();

      StartParameter startParameter = gradle.getStartParameter();

      List<String> taskNames = startParameter.getTaskNames();

      if (taskNames.contains(AppJavadocBuilderPlugin.APP_JAVADOC_TASK_NAME)
          || taskNames.contains(AppJavadocBuilderPlugin.JAR_APP_JAVADOC_TASK_NAME)
          || taskNames.contains(AppTLDDocBuilderPlugin.APP_TLDDOC_TASK_NAME)
          || taskNames.contains(AppTLDDocBuilderPlugin.JAR_APP_TLDDOC_TASK_NAME)) {

        _forceProjectHierarchyEvaluation(privateProject);
      }
    }
  }
  @Override
  public void apply(Project project) {
    WorkspaceExtension workspaceExtension =
        GradleUtil.getExtension((ExtensionAware) project.getGradle(), WorkspaceExtension.class);

    Task initBundleTask =
        GradleUtil.getTask(project.getRootProject(), RootProjectConfigurator.INIT_BUNDLE_TASK_NAME);

    _configureAnt(project);

    UpdatePropertiesTask updatePropertiesTask =
        _addTaskUpdateProperties(project, workspaceExtension);

    _addTaskBuild(project, updatePropertiesTask);

    Task warTask = GradleUtil.getTask(project, WarPlugin.WAR_TASK_NAME);

    _configureTaskWar(warTask, workspaceExtension, initBundleTask);

    _configureRootTaskDistBundle(warTask);
  }
예제 #4
0
  @Override
  public void apply(final Project project) {
    //
    // This plugin uses buildversion tasks
    //
    project.apply(
        new LinkedHashMap<String, String>() {
          {
            put("plugin", GradleCMPlugin.BUILD_VERSION_PLUGIN);
          }
        });

    //
    // Create the actual tasks that will be executed
    //
    final BuildReleaseInitTask buildInitTask =
        project.getTasks().create(INIT_TASK_NAME, BuildReleaseInitTask.class);
    buildInitTask.setDescription(
        "Create a release branch structure supporting release code promotion and publication");
    buildInitTask.setGroup(GradleInfoSource.PLUGIN_GROUP_NAME);
    final BuildReleaseMergeTask buildMergeTask =
        project.getTasks().create(MERGE_TASK_NAME, BuildReleaseMergeTask.class);
    buildMergeTask.setDescription(
        "Update the release branch with changes made to the mainline branch");
    buildMergeTask.setGroup(GradleInfoSource.PLUGIN_GROUP_NAME);
    final BuildReleaseTask buildReleaseTask =
        project.getTasks().create(RELEASE_TASK_NAME, BuildReleaseTask.class);
    buildReleaseTask.setDescription("Run the " + MERGE_TASK_NAME + " and upload targets");
    buildReleaseTask.setGroup(GradleInfoSource.PLUGIN_GROUP_NAME);

    //
    // The magic happens in a doFirst installed at task graph completion.
    // We are assuming the build is a dependency on the upload task and
    // adding our tag and branch push to occur just prior to publication.
    //
    project
        .getGradle()
        .getTaskGraph()
        .addTaskExecutionGraphListener(
            new TaskExecutionGraphListener() {
              @Override
              public void graphPopulated(final TaskExecutionGraph graph) {
                final AbstractTask uploadTask =
                    (AbstractTask)
                        new GradleInfoSource(project).getTask(buildInitTask.getUploadtask());

                if ((null == uploadTask)) {
                  project
                      .getLogger()
                      .debug(
                          "The upload task '"
                              + buildInitTask.getUploadtask()
                              + "' specified for buildreleaseupdate does not exist.  This task may be dynamic.");
                } else {
                  project
                      .getGradle()
                      .addListener(
                          new TaskExecutionListener() {
                            @Override
                            public void afterExecute(final Task task, final TaskState taskState) {
                              // Nothing after execution
                            }

                            @Override
                            public void beforeExecute(final Task task) {
                              //
                              // If we have the right task, ensure we run the tag and push
                              //
                              if (task.equals(uploadTask)) {
                                tagAndPush(project, buildInitTask, false);
                              }
                            }
                          });
                }
              }
            });
  }