Download - De Maven à SBT ScalaIO 2013
![Page 1: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/1.jpg)
De Maven à SBTStéphane Manciot
![Page 2: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/2.jpg)
Memo
• Introduction
• De Maven à SBT
o Architecture en plugin Maven versus tâches SBT
o Maven phases versus tasks dependencies
o Avantages SBT versus Maven
• SBT en entreprise
![Page 3: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/3.jpg)
Un bon outil de build doit …
• S’inscrire dans une démarche DevOps
• Être indépendant de l’environnement sur lequel il s’exécute
• S’intégrer dans l’éco-système de l’entreprise
Mais aussi…
![Page 4: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/4.jpg)
… Faciliter la vie des développeurs ;)
![Page 5: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/5.jpg)
Architecture en plugin Maven versus tâches SBT
![Page 6: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/6.jpg)
Architecture de Maven
• Une architecture reposant essentiellement sur :
o L’exécution de goals définis au sein de plugins
o Le rattachement de ces goals à des phases de l’un des 3 cycles de vie prédéfinis de Maven
o L’utilisation d’un fichier au format xml (Project Object Model) pour pouvoir configurer l’exécution des goals
![Page 7: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/7.jpg)
Phases d’un Cycle de vie Maven
ValiderValiderValiderValider
CompilerCompilerCompilerCompiler
TesterTesterTesterTester
PackagerPackagerPackagerPackager
Tests d’intégrationTests d’intégrationTests d’intégrationTests d’intégration
VérifierVérifierVérifierVérifier
InstallerInstallerInstallerInstaller
DéployerDéployerDéployerDéployer
![Page 8: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/8.jpg)
Goals mis en œuvre via des plugins
ValiderValiderValiderValider
CompilerCompilerCompilerCompiler
TesterTesterTesterTester
PackagerPackagerPackagerPackager
Tests d’intégrationTests d’intégrationTests d’intégrationTests d’intégration
VérifierVérifierVérifierVérifier
InstallerInstallerInstallerInstaller
DéployerDéployerDéployerDéployer
compiler:compilecompiler:compile
surfire:testsurfire:test
jar:jarjar:jar
![Page 9: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/9.jpg)
Définition du build au format XML
![Page 10: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/10.jpg)
Limitations du format XML
• Je ne puis exécuter que des goals qui ont été définis au sein de plugins existants
• L’apparition de nouveaux besoins requièrent :o D’attendre la mise à disposition d’une nouvelle
version du plugin
o De définir soit même un nouveau goal
![Page 11: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/11.jpg)
Ajout d’un goal avec Maven
• Création du fichier pom du plugin
![Page 12: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/12.jpg)
Ajout d’un goal avec Maven
• Création d’un Mojo
![Page 13: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/13.jpg)
Ajout d’un goal avec Maven
• Intégration du goal dans le pom
![Page 14: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/14.jpg)
Ajout d’une tâche avec SBT
• Dans SBT il y a le S pour Simple
![Page 15: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/15.jpg)
Ajout d’une tâche avec SBT
• Dans SBT il y a le S pour Simple
![Page 16: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/16.jpg)
L’architecture sbt repose sur
• L’exécution de tâches ordonnancées de manière explicite
• La configuration des tâches via des settings
• L’utilisation de Scala pour la définition des builds
![Page 17: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/17.jpg)
Phases Maven versus task dependencies
![Page 18: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/18.jpg)
Ordonnancement des goals Maven
• Exécution séquentielle des phases
• Ordonnancement implicite des goals (FIFO)
![Page 19: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/19.jpg)
L’exécution d’une tâche SBT
• Est ordonnancée de manière explicite
• Produit un résultat exploitable pour les autres tâches
![Page 20: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/20.jpg)
L’exécution d’une tâche SBT
• Est ordonnancée de manière explicite
• Produit un résultat exploitable pour les autres tâches
![Page 21: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/21.jpg)
Exemple d’exploitabilité du résultat
![Page 22: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/22.jpg)
Avantages SBT versus Maven
![Page 23: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/23.jpg)
Performances
• Parallélisation de l’exécution des tâches
• Environnement de développement interactifo Mode console SBT versus outil en ligne de
commande Maveno Scala Read Evaluate Print Loop
• Méthode ~ pour l’exécution de tâche en continu
![Page 24: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/24.jpg)
Performances Scala REPL
![Page 25: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/25.jpg)
Gestion multi-projets
• Maven impose :o un lien d’héritage pour pouvoir partager des éléments
communso Une arborescence de fichiers dans le cadre de
l’aggrégation de modules
• SBT a supprimé ces 2 contraintes o Le principe d’Hollywoodo Possibilité de créer des dépendances « distantes »
![Page 26: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/26.jpg)
Incompatibilité versions scala
• Cross Compilation SBT
• …
![Page 27: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/27.jpg)
Incompatibilité versions scala
• … versus Maven injection
nécessitant de lancer autant de fois le même build qu’il existe de version cible
![Page 28: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/28.jpg)
Gestion des dépendances (Aether versus Ivy)
• Maven via Aether ne peut gérer qu’un nombre fini de scopes
• SBT via Ivy s’appuie sur la notion de Configuration qui rend la gestion plus souple
o Permet de définir plus finement les artefacts à récupérer en fonction de la configuration choisie
![Page 29: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/29.jpg)
Gestion des dépendances
![Page 30: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/30.jpg)
SBT en entreprise
![Page 31: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/31.jpg)
Mise en place d’un référentiel d’entreprise
maven-centralmaven-central
typesafetypesafescala-
sbtscala-
sbt
![Page 32: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/32.jpg)
Conf. du gestionnaire d’artefacts
• Ajout des référentiels distants Ivyo sbt-plugin-releaseso typesafe-ivy-releaseso …
• Ajout des référentiels distants Maveno maven repo1o …
• Ajout d’un référentiel virtuel Ivy
• Ajout d’un référentiel virtuel Maven
![Page 33: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/33.jpg)
Configuration de SBT
• Ajout des nouveaux dépôts
• Bloquer tous les autres dépôts définis au sein des builds SBTo sbt -Dsbt.override.build.repos=trueo Variable SBT_OPTS
![Page 34: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/34.jpg)
Récupération des artefacts
![Page 35: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/35.jpg)
Publication des artefacts
![Page 36: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/36.jpg)
Publication des métriques dans sonar
![Page 37: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/37.jpg)
Sources - Follow us on GitHub• maven2sbt :
https://github.com/ebiznext/maven2sbt
• sbt-cxf-wsdl2java :
https://github.com/ebiznext/sbt-cxf-wsdl2java
• sbt-groovy :
https://github.com/ebiznext/sbt-groovy
• sbt-soapui:
https://github.com/ebiznext/sbt-soapui
…
![Page 38: De Maven à SBT ScalaIO 2013](https://reader038.vdocuments.pub/reader038/viewer/2022110119/555dfb86d8b42ae4628b4ee5/html5/thumbnails/38.jpg)
Questions ?