Advertisement
Janmm14

deploy.sh

Jan 11th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.81 KB | None | 0 0
  1. #!/bin/bash -e
  2. # deploy artifact from local repo easily
  3.  
  4. groupId=$1
  5. artifactId=$2
  6. version=$3
  7.  
  8. # TODO: set up local maven repo path
  9. basePath="/C/path/to/your/maven/repo/.m2/repository/$(echo $groupId | sed 's/\./\//g')/$artifactId/$version"
  10.  
  11. jar="$basePath/$artifactId-${version}a_copy.jar"
  12.  
  13. # need to copy jar since maven gives an error when trying to upload the original file
  14. cp "$basePath/$artifactId-$version.jar" "$jar"
  15.  
  16. # TODO: set up repository path
  17. url="https://repo.example.com/repository/public-"
  18.  
  19. # TODO: check path modification for snapshots and releases fits
  20. if [[ "$version" == *SNAPSHOT ]]
  21. then
  22.     url="${url}snapshots/"
  23. else
  24.     url="${url}releases/"
  25. fi
  26.  
  27. # Check if javadoc jar exists
  28. javadoc="$basePath/$artifactId-$version-javadoc.jar"
  29.  
  30. if [ -f "$javadoc" ]
  31. then
  32.     echo "Also deploying javadoc"
  33. fi
  34.  
  35. # Check if sources jar exists
  36. sources="$basePath/$artifactId-$version-sources.jar"
  37.  
  38. if [ -f "$sources" ]
  39. then
  40.     echo "Also deploying sources"
  41. fi
  42.  
  43. # Choose correct command based on existance of javadoc/sources jar
  44. then
  45.     if [ -f "$sources" ]
  46.     then
  47.         mvn deploy:deploy-file \
  48.             -DrepositoryId=janmm14-public -Durl=$url \
  49.             -DpomFile="$basePath/$artifactId-$version.pom" -Dfile="$jar" -Djavadoc="$javadoc" -Dsources="$sources"
  50.     else
  51.         mvn deploy:deploy-file \
  52.             -DrepositoryId=janmm14-public -Durl=$url \
  53.             -DpomFile="$basePath/$artifactId-$version.pom" -Dfile="$jar" -Djavadoc="$javadoc"
  54.  
  55.     fi
  56. else
  57.     if [ -f "$sources" ]
  58.     then
  59.         mvn deploy:deploy-file \
  60.             -DrepositoryId=janmm14-public -Durl=$url \
  61.             -DpomFile="$basePath/$artifactId-$version.pom" -Dfile="$jar" -Dsources="$sources"
  62.     else
  63.         mvn deploy:deploy-file \
  64.             -DrepositoryId=janmm14-public -Durl=$url \
  65.             -DpomFile="$basePath/$artifactId-$version.pom" -Dfile="$jar"
  66.     fi
  67. fi
  68.  
  69. # Remove temporary jar copy
  70. rm "$jar"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement