Exemplo n.º 1
0
  protected void configureModules(
      Project project,
      final WorkspaceExtension workspaceExtension,
      final AbstractArchiveTask[] distBundleTasks) {

    Project modulesProject = GradleUtil.getProject(project, workspaceExtension.getModulesDir());

    if (modulesProject == null) {
      return;
    }

    Action<Project> action =
        new Action<Project>() {

          @Override
          public void execute(Project project) {
            Set<Project> subprojects = project.getSubprojects();

            if (!subprojects.isEmpty()) {
              return;
            }

            GradleUtil.applyPlugin(project, LiferayPlugin.class);

            LiferayExtension liferayExtension =
                GradleUtil.getExtension(project, LiferayExtension.class);

            liferayExtension.setAppServerParentDir(workspaceExtension.getHomeDir());

            for (AbstractArchiveTask abstractArchiveTask : distBundleTasks) {

              abstractArchiveTask.into(
                  "deploy",
                  new Closure<Void>(null) {

                    @SuppressWarnings("unused")
                    public void doCall(CopySourceSpec copySourceSpec) {
                      copySourceSpec.from(JavaPlugin.JAR_TASK_NAME);
                    }
                  });
            }

            if (workspaceExtension.isModulesDefaultRepositoryEnabled()) {
              addRepositoryModules(project);
            }
          }
        };

    modulesProject.subprojects(action);
  }
Exemplo n.º 2
0
  protected void configurePluginsSDK(
      Project project,
      final WorkspaceExtension workspaceExtension,
      Copy initBundleTask,
      AbstractArchiveTask[] distBundleTasks) {

    final Project pluginsSDKProject =
        GradleUtil.getProject(project, workspaceExtension.getPluginsSDKDir());

    if (pluginsSDKProject == null) {
      return;
    }

    AntBuilder antBuilder = pluginsSDKProject.getAnt();

    antBuilder.importBuild("build.xml");

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

    File homeDir = workspaceExtension.getHomeDir();

    if (!homeDir.exists()) {
      warTask.dependsOn(initBundleTask);
    }

    Task updateSDKPropertiesTask =
        addTaskUpdateSDKProperties(pluginsSDKProject, workspaceExtension);

    Task buildTask = pluginsSDKProject.task(LifecycleBasePlugin.BUILD_TASK_NAME);

    buildTask.dependsOn(updateSDKPropertiesTask, warTask);

    for (AbstractArchiveTask abstractArchiveTask : distBundleTasks) {
      abstractArchiveTask.into(
          "deploy",
          new Closure<Void>(null) {

            @SuppressWarnings("unused")
            public void doCall(CopySpec copySpec) {
              ConfigurableFileTree configurableFileTree = pluginsSDKProject.fileTree("dist");

              configurableFileTree.builtBy(warTask);
              configurableFileTree.include("*.war");

              copySpec.from(configurableFileTree);
            }
          });
    }
  }
Exemplo n.º 3
0
  protected void configureThemes(
      Project project,
      final WorkspaceExtension workspaceExtension,
      final AbstractArchiveTask[] distBundleTasks) {

    Project themesProject = GradleUtil.getProject(project, workspaceExtension.getThemesDir());

    if (themesProject == null) {
      return;
    }

    Action<Project> action =
        new Action<Project>() {

          @Override
          public void execute(final Project project) {
            Set<Project> subproject = project.getSubprojects();

            if (!subproject.isEmpty()) {
              return;
            }

            project.setBuildDir("build_gradle");

            GradleUtil.applyPlugin(project, BasePlugin.class);
            GradleUtil.applyPlugin(project, GulpPlugin.class);

            Task assembleTask = GradleUtil.getTask(project, BasePlugin.ASSEMBLE_TASK_NAME);

            assembleTask.dependsOn(_GULP_BUILD_TASK_NAME);

            final Task createLiferayThemeJsonTask =
                addTaskCreateLiferayThemeJson(project, workspaceExtension);

            Delete cleanTask = (Delete) GradleUtil.getTask(project, BasePlugin.CLEAN_TASK_NAME);

            cleanTask.delete("build", "dist");
            cleanTask.dependsOn(
                BasePlugin.CLEAN_TASK_NAME
                    + StringUtil.capitalize(NodePlugin.NPM_INSTALL_TASK_NAME));

            Task deployTask = project.task(LiferayJavaPlugin.DEPLOY_TASK_NAME);

            deployTask.dependsOn(_GULP_DEPLOY_TASK_NAME);

            for (AbstractArchiveTask abstractArchiveTask : distBundleTasks) {

              abstractArchiveTask.into(
                  "deploy",
                  new Closure<Void>(null) {

                    @SuppressWarnings("unused")
                    public void doCall(CopySpec copySpec) {
                      ConfigurableFileTree fileTree = project.fileTree("dist");

                      fileTree.builtBy(_GULP_DEPLOY_TASK_NAME);
                      fileTree.include("*.war");

                      copySpec.from(fileTree);
                    }
                  });
            }

            TaskContainer taskContainer = project.getTasks();

            taskContainer.withType(
                ExecuteGulpTask.class,
                new Action<ExecuteGulpTask>() {

                  @Override
                  public void execute(ExecuteGulpTask executeGulpTask) {
                    executeGulpTask.dependsOn(
                        createLiferayThemeJsonTask, NodePlugin.NPM_INSTALL_TASK_NAME);
                  }
                });
          }
        };

    themesProject.subprojects(action);
  }