Table des matières

Mise en place de l'environnement

zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
chsh -s /bin/zsh
curl -fLo ~/.zprezto/modules/completion/external/src/_docker https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker

curl -s "https://get.sdkman.io" | bash
sdk install java 8u151-oracle   
sdk install maven 3.5.2
export https_proxy=http://<login>:<passwordUTLN>@proxy.univ-tln.fr:3128/ && export http_proxy=${https_proxy}
export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true -Djava.net.useSystemProxies=true"

<settings>

  <!-- Cette partie centralise l'authentification des serveurs -->  
  <servers>
  
  <!-- Pour protéger vos passwords/token :
         - generate a master password : mvn - -encrypt-master-password
         - encrypt each passwords : mvn - -encrypt-password
        -->
  
    <!-- Si vous avez un compte github créer un token avec le scope repo
  https://github.com/settings/tokens/new
  et l'ajouter ici pour utiliser git depuis maven -->
    <server>
      <id>github</id>
      <password>A_GITHUB_TOKEN</password>
    </server>
    
     <server>
	  <id>lsis-nexus</id>
	  <!-- ATTENTION UTILISER L'EMAIL UTLN -->
	  <username>VOTRE_EMAIL_UTLN</username>
	  <password>VOTRE_PASSWORD_UTLN</password>
     </server>

    <!-- Si vous avez un compte dockerhub
    vous pouvez y pousser directement vos images avec maven
    -->
    <server>
      <id>docker.io</id>
      <username>YOUR_DOCKER_LOGIN</username>
      <password>A_DOCKER_TOKEN</password>
    </server>

  <pluginGroups>
    <pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
  </pluginGroups>
  
  <!-- Sonar permet la mesure de la qualité de votre code source
  Un serveur pour l'UTLN se trouve ici : https://sonar.lsis.univ-tln.fr
  Un fois connecté vous pouvez demander un token ici :
  https://sonar.lsis.univ-tln.fr/account/security
  -->
  <profiles>
    <profile>
      <id>sonar</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <sonar.host.url>
          https://sonar.lsis.univ-tln.fr
        </sonar.host.url>
	<sonar.login>YOUR_UTLN_LOGIN</sonar.login>
	<sonar.password>A_SONAR_TOKEN</sonar.password>
      </properties>
    </profile>
  </profiles>
  
</settings>           

Pour chaque projet

# ajouter l’entrepôt maven bintray à votre ~/.m2/settings.xml
<settings>
  <profiles>
       <profile>
           <repositories>
               <repository>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
                   <id>bintray-dptinfoutln-public</id>
                   <name>bintray</name>
                   <url>https://dl.bintray.com/dptinfoutln/public</url>
               </repository>
           </repositories>
           <pluginRepositories>
               <pluginRepository>
                   <snapshots>
                       <enabled>false</enabled>
                   </snapshots>
                   <id>bintray-dptinfoutln-public</id>
                   <name>bintray-plugins</name>
                   <url>https://dl.bintray.com/dptinfoutln/public</url>
               </pluginRepository>
           </pluginRepositories>
           <id>bintray</id>
       </profile>
   </profiles>
   <activeProfiles>
       <activeProfile>bintray</activeProfile>
   </activeProfiles>
</settings>
 
#installer le client travis : https://github.com/travis-ci/travis.rb
#Si vous n'êtes pas root il faut faire une installation dans le USER_HOME
export PATH=~/.gem/ruby/2.3.0/bin:$PATH
gem install --user-install travis -v 1.8.8 --no-rdoc --no-ri
 
#construire votre projet à partir du modèle (adapter les 6 dernière lignes)
mvn -B archetype:generate \
   -DarchetypeGroupId=fr.univtln.bruno.archetype \
   -DarchetypeArtifactId=javaSimpleArchetype \
   -DarchetypeVersion=0.1.0-develop-6 \
   -DgroupId=fr.univtln.bruno.test \
   -DartifactId=monprojet \
   -Dversion=1.0-SNAPSHOT \
   -DprojectShortName=monprojet \
   -DgithubAccount=emmanuelbruno \
   -DUtlnEmail=emmanuel.bruno@univ-tln.fr
 
cd monprojet
# fixes exec perm.
chmod +x .travis.scripts/mvn.sh 
 
# fixes .travis.yml
# corrects line:  if [[ "${TRAVIS_COMMIT_MESSAGE}" == "[gitflow]"* ]] && [[ "${TRAVIS_BRANCH}" != v[0-9]* ]] && [[ "${TRAVIS_BRANCH}" != development ]] && [[ "${TRAVIS_BRANCH}" != release-* ]]; then
 
# Edit pom.xml properties
vi pom.xml 
 
git init
curl --silent https://gist.githubusercontent.com/emmanuelbruno/906d26c8ef1ff14a9dea989f71445112/raw/afcbe268816c84a78aa69341e4c800c469f1c643/.gitignore -o .gitignore
git status
git add .
git commit -m "Initial release"
 
#creates a private repository on github with the short name and a description (see. https://hub.github.com/) else manually with git remote add...
hub create -p -d "Mon projet" monprojet
 
#Maven JGitflow (M2 students only)
mvn jgitflow:feature-start
git branch
 
#Others
git branch development
git checkout development 
 
mvn package
 
#Devel. Web site (Twice first time only) 
mvn site
mvn site
firefox target/site/index.html & 
 
 
 
#See it in github
hub browse
  1. (Maven, Artifactory|Nexus|Bintray) Partager les artefacts sur un entrepôt maven privé soit à la main avec mvn deploy soit via Travis ou Jenkins.
  2. (Docker, Maven) Compiler dans un environnement standard avec Docker
  3. (Docker, Maven) Livrer dans un environnement standard avec Docker
  4. (Travis|Jenkins) Configurer un serveur de construction qui intègre le tout :
    1. réaction à chaque push sur le serveur git
    2. calcul d’un numéro de version unique
    3. compilation, test, mesure de la qualité, de la performance,…
    4. (Bintray|Artifactory|Nexus) déploiement d’un artefact et/ou d’une image docker sur un entrepôt
    5. (Heroku|Openshift) mise en test ou en production

# go to travis-ci .com or .org for private or public github, click on profile, account, sync account and enable project. 
# Pushes on github will trigger builds.

#To enable sonar and bintray secret needs to be encrypt on travis. See below for token :
#https://github.com/settings/tokens
#https://sonar.lsis.univ-tln.fr/account/security
#https://bintray.com/profile/edit

travis login --pro --github-token XXXX
travis encrypt UTLN_PASSWORD='XXXXX' --add
travis encrypt UTLN_EMAIL=XXXXX@univ-tln.fr --add
travis encrypt BINTRAY_API_KEY=XXXX --add env.matrix
travis encrypt SONAR_TOKEN=XXXX --add
git add .travis.yml 
git commit -m "adds encrypted secrets in travis.yml."
git push 

# go on travis to see the current feature building
...
git merge development

mvn jgitflow:feature-finish
...
mvn jgitflow:release-start
...
mvn jgitflow:release-finish

—- dataentry page —- type : Quickstart enseignement_tags : D14, D35 technologie_tags : Java, Maven, Git, Sonar, CI theme_tags : POO


Un développement complet en Java (Agile et Livraison Continue)