<commit_before>export JMM_VERSION="0.0.1"

# Helper functions.

jmm_helper_path_resolve() {
	if [ ${1:0:1} = "." ]; then # if starts with a .
        echo $(pwd)${1:1}
    elif [ ${1:0:1} = "~" ]; then # if starts with a ~
    	echo  $(pwd)${1:1}
    elif [ ${1:0:1} = "/" ]; then # if starts with a /
        echo  $1
    else
    	echo $(pwd)$1
    fi
}

jmm_helper_get_dir_name() {
	base=$(dirname $1)
	echo ${base##*/}
}

jmm_helper_get_class_path() {
	absPath=$(jmm_helper_path_resolve $1)
	jmmSize=${#JMMPATH}+5 # remove /src/
	absSize=${#absPath}
	absPath=${absPath:0:absSize-5} # remove .class
	echo ${absPath:$jmmSize}
}

jmm_helper_find_up() {
  local path
  path=$1
  while [ "$path" != "" ] && [ ! -d "$path/$2" ]; do
    path=${path%/*}
  done
  echo "$path"
}

jmm_helper_find_src() {
  local dir
  dir="$(jmm_helper_find_up $1 'src')"
  if [ -e "$dir/src" ]; then
    echo "$dir/src"
  fi
}

jmm_helper_resolve() {
    cd "$1" 2>/dev/null || return $?  # cd to desired directory; if fail, quell any error messages but return exit status
    echo "`pwd -P`" # output full, link-resolved path
}

jmm_helper_build_jar() {
	mkdir -p $JMMPATH/bin
	mkdir -p $JMMPATH/pkg
	jarName=$(jmm_helper_get_dir_name $1)
	classFiles=""
	classPaths=""
	for file; do
		classFiles="$classFiles $file"
		classPaths="$classPaths -C $JMMPATH/pkg ./$(jmm_helper_get_class_path $file).class"
	done
	javac -d $JMMPATH/pkg $classFiles
	jar cf $JMMPATH/bin/$jarName.jar $classPaths
}

# Commands.

jmm_build() {
    # need to find all dependancies and add those files too
    # need to find the file that has the main method and make that first in the list
    files=""
    for file in $(find $1 -name '*.java' ); do
        files="$files $file"
    done
    jmm_helper_build_jar $files
}

jmm_clean() {
	rm -rf $JMMPATH/bin/*<commit_msg>Looking for main method in build command<commit_after>export JMM_VERSION="0.0.1"

# Helper functions.

jmm_helper_path_resolve() {
	if [ ${1:0:1} = "." ]; then # if starts with a .
        echo $(pwd)${1:1}
    elif [ ${1:0:1} = "~" ]; then # if starts with a ~
    	echo  $(pwd)${1:1}
    elif [ ${1:0:1} = "/" ]; then # if starts with a /
        echo  $1
    else
    	echo $(pwd)$1
    fi
}

jmm_helper_get_dir_name() {
	base=$(dirname $1)
	echo ${base##*/}
}

jmm_helper_get_class_path() {
	absPath=$(jmm_helper_path_resolve $1)
	jmmSize=${#JMMPATH}+5 # remove /src/
	absSize=${#absPath}
	absPath=${absPath:0:absSize-5} # remove .class
	echo ${absPath:$jmmSize}
}

jmm_helper_find_up() {
  local path
  path=$1
  while [ "$path" != "" ] && [ ! -d "$path/$2" ]; do
    path=${path%/*}
  done
  echo "$path"
}

jmm_helper_find_src() {
  local dir
  dir="$(jmm_helper_find_up $1 'src')"
  if [ -e "$dir/src" ]; then
    echo "$dir/src"
  fi
}

jmm_helper_resolve() {
    cd "$1" 2>/dev/null || return $?  # cd to desired directory; if fail, quell any error messages but return exit status
    echo "`pwd -P`" # output full, link-resolved path
}

jmm_helper_build_jar() {
	mkdir -p $JMMPATH/bin
	mkdir -p $JMMPATH/pkg
	jarName=$(jmm_helper_get_dir_name $1)
	classFiles=""
	classPaths=""
	for file; do
		classFiles="$classFiles $file"
		classPaths="$classPaths -C $JMMPATH/pkg ./$(jmm_helper_get_class_path $file).class"
	done
	javac -d $JMMPATH/pkg $classFiles
	jar cf $JMMPATH/bin/$jarName.jar $classPaths
}

# Commands.

jmm_build() {
    # need to find all dependancies and add those files too
    # need to find the file that has the main method and make that first in the list
    main=""
    files=""
    for file in $(find $1 -name '*.java' ); do
        if [ -z $main ] && grep -q main "$file"; then
            main="$file"
        else
            files="$files $file"
        fi
    done
    jmm_helper_build_jar $main $files
}

jmm_clean() {
	rm -rf $JMMPATH/bin/*
{'fraction_non_alphanumeric': 0.16333508679642295, 'fraction_numerical': 0.015781167806417674, 'mean_word_length': 3.1562841530054646, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2284149', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1484, 'n_words': 382}