Build JAR usando Maven

Pessoal,

Preciso criar um simples JAR utilizando o Maven, sempre utilizei o Ant/build para realizar essas tarefas e isso era muito fácil.
Sei que preciso utilizar um plugin, mas até agora não achei nenhum exemplo que me atenda.
Minha aplicação possui arquivos de configuração hibernate distintos para cada ambiente: desenvolvimento, homologação e produção.
Alguém teria um exemplo para me ajudar?

Muito obrigado,

Israel

Defina no seu pom a seguinte tag:

Depois é so rodar o comando

ou

t+

Criar o jar é fácil, mas eu preciso separar por ambiente: desenv, homologacao e producao.
:frowning:

Não lembro de ter visto algum plugin do tipo para o Maven, entretanto, é possível você utilizar scripts de ANT dentro do Maven (é bom qdo você já tem coisa legal do ANT funcionando).

Você pode usar profiles: http://maven.apache.org/guides/introduction/introduction-to-profiles.html

Daí depois é só adicionar -PPROD na hora de gerar o artefato

Consegui fazer o que queria. :slight_smile:
Não sei se é a melhor forma, mas funcionou. Usei esses dois plugins: maven-resources-plugin e maven-jar-plugin

Ficou da seguinte forma:

        <!-- PROFILES -->
	<profiles>
		<!-- DESENVOLVIMENTO -->
		<profile>
			<id>desenvolvimento</id>
			<properties>
				<ambiente>desenvolvimento</ambiente>
			</properties>
			<build>
				<plugins>
					<!-- COPIA ARQUIVOS DE CONFIGURACAO DESENVOLVIMENTO -->
					<plugin>
						<artifactId>maven-resources-plugin</artifactId>
						<version>2.4.3</version>
						<executions>
							<execution>
								<id>copy-resources</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>copy-resources</goal>
								</goals>
								<configuration>
									<outputDirectory>${basedir}/target/classes</outputDirectory>
									<resources>
										<resource>
											<directory>ambiente/Desenvolvimento</directory>
											<filtering>true</filtering>
										</resource>
									</resources>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- /COPIA ARQUIVOS DE CONFIGURACAO DESENVOLVIMENTO -->
					<!-- EMPACOTA ARQUIVOS DESENVOLVIMENTO -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>2.3.1</version>
						<configuration>
							<useDefaultManifestFile>true</useDefaultManifestFile>
							<includes>
								<include>**/*.class</include>
								<include>**/*.properties</include>
								<include>resources/**/*.xml</include>
								<include>**/*.xml</include>
							</includes> 
						</configuration>
					</plugin>
					<!-- /EMPACOTA ARQUIVOS DESENVOLVIMENTO -->
				</plugins>
			</build>
		</profile>
		<!-- /DESENVOLVIMENTO -->
		<!-- HOMOLOGACAO -->
		<profile>
			<id>homologacao</id>
			<properties>
				<ambiente>homologacao</ambiente>
			</properties>
			<build>
				<plugins>
					<!-- COPIA ARQUIVOS DE CONFIGURACAO HOMOLOGACAO -->
					<plugin>
						<artifactId>maven-resources-plugin</artifactId>
						<version>2.4.3</version>
						<executions>
							<execution>
								<id>copy-resources</id>
								<!-- here the phase you need -->
								<phase>prepare-package</phase>
								<goals>
									<goal>copy-resources</goal>
								</goals>
								<configuration>
									<outputDirectory>${basedir}/target/classes</outputDirectory>
									<resources>
										<resource>
											<directory>ambiente/Homologacao</directory>
											<filtering>true</filtering>
										</resource>
									</resources>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- /COPIA ARQUIVOS DE CONFIGURACAO HOMOLOGACAO -->
					<!-- EMPACOTA ARQUIVOS HOMOLOGACAO -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>2.3.1</version>
						<configuration>
							<useDefaultManifestFile>true</useDefaultManifestFile>
							<includes>
								<include>**/*.class</include>
								<include>**/*.properties</include>
								<include>resources/**/*.xml</include>
								<include>**/*.xml</include>
							</includes> 
						</configuration>
					</plugin>
					<!-- /EMPACOTA ARQUIVOS HOMOLOGACAO -->
				</plugins>
			</build>
		</profile>
		<!-- /HOMOLOGACAO -->
		<!-- PRODUCAO -->
		<profile>
			<id>producao</id>
			<properties>
				<ambiente>producao</ambiente>
			</properties>
			<build>
				<plugins>
					<!-- COPIA ARQUIVOS DE CONFIGURACAO PRODUCAO -->
					<plugin>
						<artifactId>maven-resources-plugin</artifactId>
						<version>2.4.3</version>
						<executions>
							<execution>
								<id>copy-resources</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>copy-resources</goal>
								</goals>
								<configuration>
									<outputDirectory>${basedir}/target/classes</outputDirectory>
									<resources>
										<resource>
											<directory>ambiente/Producao</directory>
											<filtering>true</filtering>
										</resource>
									</resources>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- COPIA ARQUIVOS DE CONFIGURACAO PRODUCAO -->
					<!-- EMPACOTA ARQUIVOS PRODUCAO -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>2.3.1</version>
						<configuration>
							<useDefaultManifestFile>true</useDefaultManifestFile>

								 
								<includes>
								<include>**/*.class</include>
								<include>**/*.properties</include>
								<include>resources/**/*.xml</include>
								<include>**/*.xml</include>
								</includes> 
								
								<!--
								<excludes> <exclude>*.xml</exclude>
								<exclude>resources/hibernate.cfg.xml</exclude> </excludes>
								 -->

						</configuration>
					</plugin>
					<!-- EMPACOTA ARQUIVOS PRODUCAO -->
				</plugins>
			</build>
		</profile>
		<!-- /PRODUCAO -->
	</profiles>

Valeu pessoal pelas dicas.

Abs,