<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tellaw.org &#187; maven</title>
	<atom:link href="http://www.tellaw.org/tag/maven/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tellaw.org</link>
	<description>La technologie doit devenir simple...</description>
	<lastBuildDate>Fri, 02 Apr 2010 14:48:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Maven &#8211; une alternative à ANT pour la compilation&#8230;</title>
		<link>http://www.tellaw.org/2008/04/24/maven-une-alternative-a-ant-pour-la-compilation/</link>
		<comments>http://www.tellaw.org/2008/04/24/maven-une-alternative-a-ant-pour-la-compilation/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 15:32:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=44</guid>
		<description><![CDATA[En utilisant Maven vous pourrez automatiser les taches r&#233;barbatives d&#8217;un projet web. Il prendra en charge par exemple la version de librairies de vos d&#233;pendances, le projet Eclipse, les builds et les tests unitaires. Cet article va vous montrer dans un projet simple l&#8217;utilisation de Maven avec des librairies externes. A la grande diff&#233;rence de [...]]]></description>
			<content:encoded><![CDATA[<p>En utilisant Maven vous pourrez automatiser les taches r&eacute;barbatives d&#8217;un projet web. Il prendra en charge par exemple la version de librairies de vos d&eacute;pendances, le projet Eclipse, les builds et les tests unitaires. Cet article va vous montrer dans un projet simple l&#8217;utilisation de Maven avec des librairies externes. A la grande diff&eacute;rence de Ant, ou vous d&eacute;crivez les taches &agrave; r&eacute;aliser, dans Maven vous d&eacute;crivez votre projet, et lui connait les taches &agrave; r&eacute;aliser. C&#8217;est une approche diff&eacute;rente, amenant l&#8217;utilisation de fichiers de configurations plus l&eacute;gers, plus lisible, tr&egrave;s efficace&#8230;</p>
<p><span id="more-44"></span></p>
<p><strong>1) Installation de Maven :</strong><br/><br />
L&#8217;installation de Maven sous Windows est particuli&egrave;rement simple. Il suffit de t&eacute;l&eacute;charger l&#8217;install depuis le site officiel (<a href="http://maven.apache.org/" hreflang="fr">http://maven.apache.org/</a>), et d&#8217;ajouter dans votre path le chemin vers son r&eacute;pertoire bin (chez moi : C:\Program Files\Apache Software Foundation\Maven 1.0.2\bin).  A ce stade vous pouvez tester maven en lan&ccedil;ant en ligne de commande : <strong>Maven</strong>.  Lors de son installation Maven doit cr&eacute;er les variables d&#8217;environement :</p>
<blockquote><p>
<b>MAVEN_HOME</b> -&gt; C:\Program Files\Apache Software Foundation\Maven 1.0.2
</p></blockquote>
<p>Vous devrez configurer une variable dzns eclipse pour permettre une parfaite interaction entre les deux :</p>
<blockquote><p>
Window -&gt; Preferences -&gt; Java -&gt; Build Path -&gt; Classpath Variables -&gt; New<br/><br />
<b>ajouter :</b> MAVEN_REPO -&gt; votre repository<br/><br />
(chez moi : C:`\Documents and Settings\Eric\.maven\repository)
</p></blockquote>
<p><em>Attention le repository n&#8217;existe qu&#8217;apr&egrave;s la premi&egrave;re ex&eacute;cution de maven</em>  <strong>2) Cr&eacute;ation de l&#8217;arborescence de votre projet :</strong>  L&#8217;arborescence des projets sous Maven doit respecter une recommandation dsponible ici : <a href="http://maven.apache.org/reference/conventions.html#Directory_Structure" hreflang="en">Maven Conventions</a>  Voici l&#8217;arborescence cible :</p>

<div class="wp_syntax"><div class="code"><pre class="text">/+- src
/|  +- main
/|  |  +- java
/|  |  |  +- ...|  |  +- resources
/|  |     +- ...|  +- test
/|  |  +- java
/|  |  |  +- ...|  |  +- resources
/|  |     +- ...|  +- site
/|     +- xdoc
/|        +- ...+- target
/|  +- ...+- project.xml
+- README.tx
+- LICENSE.txt</pre></div></div>

<p><strong>3) Le fichier de configuration de Maven (project.xml) :</strong>  <em>project.xml</em></p>

<div class="wp_syntax"><div class="code"><pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;project<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		POM : Project Object Model, c'est le modÃ¨le objet du projet.	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;pomVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>1<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/pomVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>tellaw.org<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;currentVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>0.1-DEMO<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/currentVersion<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;organization</span> <span style="font-weight: bold; color: black;">/&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;repository</span><span style="font-weight: bold; color: black;">/&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>TagLib Sample<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		C'est le nom de l'artifact  réaliser. 
		Sous Maven, les livrables à réaliser sont des artifacts.	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>taglib_sample<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		Les dépendances : Maven va tenir à jour vos dépendances depuis son repository.		
		- Il téléchargera depuis un repository distant la version voulue si vouq ne la possédez pas encore.		
		- Notez la propriété WAR.BUNDLE = true, permettant d'embarquer la dépendance dans le war de livraison. 	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependencies<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>log4j<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>1.2.8<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;war</span>.bundle<span style="font-weight: bold; color: black;">&gt;</span></span>true<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/war</span>.bundle<span style="font-weight: bold; color: black;">&gt;</span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/properties<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;id<span style="font-weight: bold; color: black;">&gt;</span></span></span>junit<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/id<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>3.8.1<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>servletapi<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>servletapi<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>2.4-20040521<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
&nbsp;
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>jspapi<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/groupId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>jsp-api<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/artifactId<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;version<span style="font-weight: bold; color: black;">&gt;</span></span></span>2.0-20040521<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/version<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependency<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/dependencies<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
&nbsp;
	<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--		
		Définition du projet.	
	--&gt;</span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;build<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;sourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>src/main/java<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/sourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;unitTestSourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>src/test/java<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/unitTestSourceDirectory<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resources<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;resource<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;directory<span style="font-weight: bold; color: black;">&gt;</span></span></span>src/main/webapp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/directory<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filtering<span style="font-weight: bold; color: black;">&gt;</span></span></span>false<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filtering<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resource<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/resources<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;unitTest<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;includes<span style="font-weight: bold; color: black;">&gt;</span></span></span>				
				<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include<span style="font-weight: bold; color: black;">&gt;</span></span></span>**/*Test.java<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/include<span style="font-weight: bold; color: black;">&gt;</span></span></span>			
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/includes<span style="font-weight: bold; color: black;">&gt;</span></span></span>		
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/unitTest<span style="font-weight: bold; color: black;">&gt;</span></span></span>	
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/build<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/project<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre></div></div>

<p>
<strong>4) Configuration du projet pour le workspace d&#8217;eclipse :</strong> <br/></p>
<p>Tous les utilisateurs d&#8217;&eacute;clipse connaissent le soucis de d&eacute;pendances perdues en cours de projets, a re-centraliser r&eacute;guli&eacute;rement, ou dont les versions sont diff&eacute;rentes entre les intervenant du projet !!!!<br/><br />
Nous avons tous un jour hurler notre rage face &agrave; un Eclipse qui n&#8217;avait plus ses fichiers projets : <em>.classpath</em> et <em>.project</em>&#8230;  Et bien c&#8217;est termin&eacute;, Maven peux g&eacute;n&eacute;rer pour vous les fichiers de configuration projet d&#8217;Eclipse, la commande magique ???? simpleeee :</p>
<blockquote><p>maven eclipse</p></blockquote>
<p style="text-align: center;"><a href="http://www.tellaw.org/wp-content/uploads/2008/04/maven_eclipse.gif"><img width="300" height="211" alt="" src="http://www.tellaw.org/wp-content/uploads/2008/04/maven_eclipse.gif" title="maven_eclipse" class="alignnone size-full wp-image-45" /></a></p>
<p><strong>R&eacute;sultat :</strong></p>
<ul>
<li>Maven va v&eacute;rifier les d&eacute;pendances et t&eacute;l&eacute;charger celles dont le projet &agrave; besoin.</li>
<li>Maven va reconstruire les fichiers projets : .classpath et .project</li>
<li>Eclipse se basera sur les librairies de Maven.</li>
</ul>
<p><strong>5) Compilation et livraison sous Maven :</strong>  La compilation est simple avec Maven :</p>
<blockquote><p>
<strong>maven war</strong> -&gt; Cr&eacute;ation d&#8217;un war (Compilation, Tests Unitaires&#8230;).<br/><br />
<strong> maven jar</strong> -&gt; Cr&eacute;ation d&#8217;un jar avec le projet.<br/><br />
<strong> maven java:compile</strong>-&gt; Simple compilation du projet.<br/><br />
<strong> maven site</strong> -&gt; Cr&eacute;ation d&#8217;un site d&#8217;information sur la compilation et la documentation (sortie dans target/docs).<br/><br />
<strong> maven clean</strong> -&gt; Nettoyage des fichers de sortie de maven.<br/><br />
<strong> maven eclipse</strong> -&gt; Reconstruit le projet eclipse.</p></blockquote>
<p style="text-align: center;"><a href="http://www.tellaw.org/wp-content/uploads/2008/04/maven_war.gif"><img width="300" height="209" alt="" src="http://www.tellaw.org/wp-content/uploads/2008/04/maven_war.gif" title="maven_war" class="alignnone size-full wp-image-46" /></a></p>
<p>Lors de chaque tache Maven validera que toutes ses d&eacute;pendances sont pr&eacute;sentes, si ce n&#8217;est pas le cas, il les t&eacute;l&eacute;charges depuis <a target="_blank" href="http://www.ibiblio.org/maven/" hreflang="fr">http://www.ibiblio.org/maven/</a> <strong>Maven utilise le repertoire target pour sortir ses fichiers.</strong> Beaucoup d&#8217;options et de plugins existent pour Maven, je ne peux &eacute;videmment pas en faire un listing. Cet article donne un kit de quickstart, pas une formation compl&egrave;te.  <strong>Liens utiles  :</strong></p>
<ul>
<li><a target="_blank" href="http://maven.apache.org/" hreflang="fr">Site officiel</a></li>
<li><a target="_blank" href="http://www.theserverside.com/articles/article.tss?l=MavenMagic" hreflang="en">Tutorial Maven</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/24/maven-une-alternative-a-ant-pour-la-compilation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
