<commit_before>package org.akhikhl.gradle.onejar

import org.gradle.api.*
import org.gradle.api.plugins.*
import org.gradle.api.tasks.*
import org.gradle.api.tasks.bundling.*


/**
 * Gradle plugin for onejar generation
 * @author akhikhl
 *
 */
class OneJarPlugin implements Plugin<Project> {

  void apply(final Project project) {

    // the project supposed to be "java" or "groovy" already

    project.extensions.create('onejar', OneJarPluginExtension)

    project.configurations { onejar }

    project.dependencies { onejar 'com.simontuffs:one-jar-ant-task:0.97' }

    project.task('prepareOneJar') { dependsOn project.tasks.assemble, project.tasks.check }

    project.afterEvaluate {

      if(!project.tasks.jar.manifest.attributes.'Main-Class' && project.ext.has('mainClass')) {
        // translate netbeans-compatible declaration of main-class to jar-manifest-attribute
        project.jar {
          manifest { attributes 'Main-Class': project.ext.mainClass }
        }
      }

      String outputBaseDir = "${project.buildDir}/output"

      def mainJar = project.onejar.mainJar
      if(mainJar == null)
      mainJar = project.tasks.jar.archivePath
      else if(mainJar instanceof Closure)
      mainJar = mainJar()

      if(mainJar instanceof String)
      mainJar = new File(mainJar)

      project.onejar.beforeProductGeneration.each { obj ->
        if(obj instanceof Closure)
        obj()<commit_msg>gradle-onejar: introduced tasks 'run' and 'debug'<commit_after>package org.akhikhl.gradle.onejar

import org.gradle.api.*
import org.gradle.api.plugins.*
import org.gradle.api.tasks.*
import org.gradle.api.tasks.bundling.*


/**
 * Gradle plugin for onejar generation
 * @author akhikhl
 *
 */
class OneJarPlugin implements Plugin<Project> {

  void apply(final Project project) {

    // the project is supposed to be "java" or "groovy" already

    project.extensions.create('onejar', OneJarPluginExtension)

    project.configurations { onejar }

    project.dependencies { onejar 'com.simontuffs:one-jar-ant-task:0.97' }

    project.task('prepareOneJar') { dependsOn project.tasks.assemble, project.tasks.check }

    project.task 'run', type: JavaExec
    project.task 'debug', type: JavaExec

    project.afterEvaluate {

      def mainClass
      if(project.ext.has('mainClass'))
        mainClass = project.ext.mainClass
      else
        mainClass = project.tasks.jar.manifest.attributes.'Main-Class'

      project.tasks.run {
        dependsOn: project.tasks.classes
        main = mainClass
        classpath = project.sourceSets.main.runtimeClasspath
        if(project.ext.has('programArgs'))
          args project.ext.programArgs
      }

      project.tasks.debug {
        dependsOn: project.tasks.classes
        main = mainClass
        classpath = project.sourceSets.main.runtimeClasspath
        if(project.ext.has('programArgs'))
          args project.ext.programArgs
        debug = true
      }

      if(project.tasks.jar.manifest.attributes.'Main-Class' != mainClass) {
        // translate netbeans-compatible declaration of main-class to jar-manifest-attribute
        project.jar {
          manifest { attributes 'Main-Class': project.ext.mainClass }
        }
      }

      String outputBaseDir = "${project.buildDir}/output"

      def mainJar = project.onejar.mainJar
      if(mainJar == null)
      mainJar = project.tasks.jar.archivePath
      else if(mainJar instanceof Closure)
      mainJar = mainJar()

      if(mainJar instanceof String)
      mainJar = new File(mainJar)

      project.onejar.beforeProductGeneration.each { obj ->
        if(obj instanceof Closure)
        obj()
{'fraction_non_alphanumeric': 0.10779753761969904, 'fraction_numerical': 0.0016415868673050615, 'mean_word_length': 2.876988335100742, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1797201', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1052, 'n_words': 219}