public Map<String, String> getBundleDefaultInstructions() {
    Map<String, String> map = new HashMap<>();

    map.put(Constants.BUNDLE_SYMBOLICNAME, project.getName());
    map.put(Constants.BUNDLE_VENDOR, "Liferay, Inc.");
    map.put(Constants.DONOTCOPY, "(.touch)");
    map.put(Constants.DSANNOTATIONS, "*");
    map.put(Constants.METATYPE, "*");
    map.put(Constants.PLUGIN, StringUtil.merge(_BND_PLUGIN_CLASS_NAMES, ","));
    map.put(Constants.SOURCES, "false");

    map.put("Git-Descriptor", "${system-allow-fail;git describe --dirty --always}");
    map.put("Git-SHA", "${system-allow-fail;git rev-list -1 HEAD}");

    JavaCompile javaCompile =
        (JavaCompile) GradleUtil.getTask(project, JavaPlugin.COMPILE_JAVA_TASK_NAME);

    CompileOptions compileOptions = javaCompile.getOptions();

    map.put("Javac-Debug", _getOnOffValue(compileOptions.isDebug()));
    map.put("Javac-Deprecation", _getOnOffValue(compileOptions.isDeprecation()));

    String encoding = compileOptions.getEncoding();

    if (Validator.isNull(encoding)) {
      encoding = System.getProperty("file.encoding");
    }

    map.put("Javac-Encoding", encoding);

    map.put("-jsp", "*.jsp,*.jspf");
    map.put("-sass", "*");

    return map;
  }
  private FileTree getJavaSourceTree() {
    FileTree javaSourceTree = null;
    TaskCollection<JavaCompile> javaCompileTasks =
        this.getProject().getTasks().withType(JavaCompile.class);

    for (JavaCompile task : javaCompileTasks) {
      if (javaSourceTree == null) {
        javaSourceTree = task.getSource();
      } else {
        javaSourceTree = javaSourceTree.plus(task.getSource());
      }
    }

    return excludeOutputDirectory(javaSourceTree);
  }
  protected void configureTaskCompileJSP(Project project) {
    boolean jspPrecompileEnabled =
        GradleUtil.getProperty(project, JSP_PRECOMPILE_ENABLED_PROPERTY_NAME, false);

    if (!jspPrecompileEnabled) {
      return;
    }

    JavaCompile javaCompile =
        (JavaCompile) GradleUtil.getTask(project, JspCPlugin.COMPILE_JSP_TASK_NAME);

    String dirName = _osgiHelper.getBundleSymbolicName(project) + "-" + project.getVersion();

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

    File dir = new File(liferayExtension.getLiferayHome(), "work/" + dirName);

    javaCompile.setDestinationDir(dir);
  }
Ejemplo n.º 4
0
 private void createCompileJavaTaskForBinary(
     final SourceSet sourceSet, final JavaSourceSet javaSourceSet, Project target) {
   JavaCompile compileTask =
       target.getTasks().create(sourceSet.getCompileJavaTaskName(), JavaCompile.class);
   compileTask.setDescription(String.format("Compiles %s.", javaSourceSet));
   compileTask.setSource(javaSourceSet.getSource());
   compileTask.dependsOn(javaSourceSet);
   ConventionMapping conventionMapping = compileTask.getConventionMapping();
   conventionMapping.map(
       "classpath",
       new Callable<Object>() {
         public Object call() throws Exception {
           return javaSourceSet.getCompileClasspath().getFiles();
         }
       });
   conventionMapping.map(
       "destinationDir",
       new Callable<Object>() {
         public Object call() throws Exception {
           return sourceSet.getOutput().getClassesDir();
         }
       });
 }