Skip to content

Instantly share code, notes, and snippets.

@hlzhang
Last active September 26, 2019 21:57
Show Gist options
  • Save hlzhang/48860851bcb1c04432f3507bb20c2e5c to your computer and use it in GitHub Desktop.
Save hlzhang/48860851bcb1c04432f3507bb20c2e5c to your computer and use it in GitHub Desktop.

Revisions

  1. @chshawkn chshawkn revised this gist Sep 26, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions fixContentRoot.sh
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,8 @@ function fix_content_root() {
    echo ${target};
    sed -Ei 's#<content url="file://\$MODULE_DIR\$/(\.\./)+src/main/resources" />##g' ${target};
    sed -i '/<content url="file:\/\/$MODULE_DIR$\/..\/src\/main\/resources">/{:a;N;/<\/content>/!ba};/<sourceFolder url="file:\/\/$MODULE_DIR$\/..\/src\/main\/resources" type="java-resource" \/>/d' ${target};
    sed -i '/<content url="file:\/\/$MODULE_DIR$\/..\/..\/src\/main\/resources">/{:a;N;/<\/content>/!ba};/<sourceFolder url="file:\/\/$MODULE_DIR$\/..\/..\/src\/main\/resources" type="java-resource" \/>/d' ${target};
    sed -i '/<content url="file:\/\/$MODULE_DIR$\/..\/..\/..\/src\/main\/resources">/{:a;N;/<\/content>/!ba};/<sourceFolder url="file:\/\/$MODULE_DIR$\/..\/..\/..\/src\/main\/resources" type="java-resource" \/>/d' ${target};
    done
    }

  2. @chshawkn chshawkn created this gist Sep 22, 2019.
    13 changes: 13 additions & 0 deletions fixContentRoot.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    set -x

    function fix_content_root() {
    local in_directory="$1"
    local targets=($(grep -E -l --include \*.iml '<content url="file://\$MODULE_DIR\$/(\.\./)+src/main/resources"' -r ${in_directory} | grep -v 'fixContentRoot.sh'))
    for target in ${targets[@]}; do
    echo ${target};
    sed -Ei 's#<content url="file://\$MODULE_DIR\$/(\.\./)+src/main/resources" />##g' ${target};
    sed -i '/<content url="file:\/\/$MODULE_DIR$\/..\/src\/main\/resources">/{:a;N;/<\/content>/!ba};/<sourceFolder url="file:\/\/$MODULE_DIR$\/..\/src\/main\/resources" type="java-resource" \/>/d' ${target};
    done
    }

    fix_content_root "${HOME}/Documents/IdeaProjects"