<commit_before>#!/bin/bash -e
# depends libxml-simple-perl

tcrepo=http://builder.neo4j.org/guestAuth/repository/download/bt18/lastSuccessful
mvnrepo=http://repo.neo4j.org/content/repositories/snapshots

function work {
    deploy_defaults neo4j-graph-algo jmx neo4j-kernel neo4j-lucene-index neo4j-shell neo4j-udc server-api

    deploy neo4j docs javadoc sources test-sources
    deploy neo4j-community docs javadoc sources test-sources
    
    deploy neo4j-server site static-web docs javadoc sources test-sources tests

    deploy_tarball neo4j-examples download
    deploy neo4j-examples docs sources test-sources tests site

    deploy_tarball neo4j-server-examples download
    deploy neo4j-server-examples docs site sources test-sources tests
}

function deploy_defaults {
    for artifact in $@  ; do
        deploy $artifact docs javadoc sources test-sources tests
    done
}

function repeat_command {
    thecommand=$1
    for counter in 1 2 3
    do
        if $thecommand
        then
            break
        fi
        echo "Command failed ($counter): $thecommand"
    done
}

function deploy_maven_jar {
    artifact=$1
    version=$2
    filename=$artifact-$version.jar
    curlcommand="curl -f -O $tcrepo/$artifact/$filename"
    echo $curlcommand
    $curlcommand
    deploycommand="mvn deploy:deploy-file -Durl=$mvnrepo -DrepositoryId=snapshots -DuniqueVersion=false -Dfile=$filename -Dpackaging=jar -DpomFile=pom.xml"
    echo $deploycommand
    repeat_command "$deploycommand"
}

function deploy_maven_type_classifier {
    artifact=$1
    version=$2
    type=$3
    classifier=$4
    filename=$artifact-$version-$classifier.$type
    curlcommand="curl -f -O $tcrepo/$artifact/$filename"
    echo $curlcommand
    $curlcommand
    deploycommand="mvn deploy:deploy-file -Durl=$mvnrepo -DrepositoryId=snapshots -DuniqueVersion=false -Dfile=$filename -Dpackaging=$type -Dclassifier=$classifier -DpomFile=pom.xml"
    echo $deploycommand
    repeat_command "$deploycommand"
}

# uses the global $artifact as input
function get_version {
    curlcommand="curl -f -s -O $tcrepo/$artifact/pom.xml"
    echo $curlcommand
    $curlcommand
    version=$( ./xmlgrep pom.xml )
    echo "**************************************************************"
    echo "artifact:$artifact  version:$version"
}

function deploy_tarball {
    artifact=$1
    classifier=$2
    type=tar.gz
    get_version
    deploy_maven_type_classifier $artifact $version $type $classifier
}

function deploy {
    artifact=$1
    get_version
    deploy_maven_jar $artifact $version
    first=1
    for classifier in $@  ; do
        if [ -z $first ] ; then
            deploy_maven_type_classifier $artifact $version jar $classifier
        fi
        unset first
    done
}

## prepare working dir
[ -e target/upload ] && rm -rf target/upload
mkdir -p target/upload
cd target/upload<commit_msg>More refactoring, keeping curl less silent.<commit_after>#!/bin/bash -e
# depends libxml-simple-perl

tcrepo=http://builder.neo4j.org/guestAuth/repository/download/bt18/lastSuccessful
mvnrepo=http://repo.neo4j.org/content/repositories/snapshots

function work {
    deploy_defaults neo4j-graph-algo jmx neo4j-kernel neo4j-lucene-index neo4j-shell neo4j-udc server-api

    deploy neo4j docs javadoc sources test-sources
    deploy neo4j-community docs javadoc sources test-sources
    
    deploy neo4j-server site static-web docs javadoc sources test-sources tests

    deploy_tarball neo4j-examples download
    deploy neo4j-examples docs sources test-sources tests site

    deploy_tarball neo4j-server-examples download
    deploy neo4j-server-examples docs site sources test-sources tests
}

function deploy_defaults {
    for artifact in $@  ; do
        deploy $artifact docs javadoc sources test-sources tests
    done
}

function repeat_command {
    thecommand=$1
    echo $thecommand
    for counter in 1 2 3
    do
        if $thecommand
        then
            break
        fi
        echo "Command failed ($counter): $thecommand"
    done
}

function fetch_artifact {
    artifact=$1
    filename=$2
    curlcommand="curl -f -O $tcrepo/$artifact/$filename"
    repeat_command "$curlcommand"
}

function deploy_maven_jar {
    artifact=$1
    version=$2
    filename=$artifact-$version.jar
    fetch_artifact $artifact $filename
    deploycommand="mvn deploy:deploy-file -Durl=$mvnrepo -DrepositoryId=snapshots -DuniqueVersion=false -Dfile=$filename -Dpackaging=jar -DpomFile=pom.xml"
    repeat_command "$deploycommand"
}

function deploy_maven_type_classifier {
    artifact=$1
    version=$2
    type=$3
    classifier=$4
    filename=$artifact-$version-$classifier.$type
    fetch_artifact $artifact $filename
    deploycommand="mvn deploy:deploy-file -Durl=$mvnrepo -DrepositoryId=snapshots -DuniqueVersion=false -Dfile=$filename -Dpackaging=$type -Dclassifier=$classifier -DpomFile=pom.xml"
    repeat_command "$deploycommand"
}


# uses the global $artifact as input
function get_version {
    fetch_artifact $artifact pom.xml
    version=$( ./xmlgrep pom.xml )
    echo "**************************************************************"
    echo "artifact:$artifact  version:$version"
}

function deploy_tarball {
    artifact=$1
    classifier=$2
    type=tar.gz
    get_version
    deploy_maven_type_classifier $artifact $version $type $classifier
}

function deploy {
    artifact=$1
    get_version
    deploy_maven_jar $artifact $version
    first=1
    for classifier in $@  ; do
        if [ -z $first ] ; then
            deploy_maven_type_classifier $artifact $version jar $classifier
        fi
        unset first
    done
}

## prepare working dir
[ -e target/upload ] && rm -rf target/upload
mkdir -p target/upload
cd target/upload
{'fraction_non_alphanumeric': 0.1080375782881002, 'fraction_numerical': 0.010786360473208072, 'mean_word_length': 3.4739299610894943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '483591', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1698, 'n_words': 429}