You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by madeOfStarStuff <so...@hotmail.com> on 2010/12/10 13:18:13 UTC

Maven create JAR

Hi, I'm sure this will be simple one...

My pom.xml is configured to create a jar; which is does. However, I've added
some config to inlude and exclude certain files etc.  When I do this, none
of the class files are added (i.e. package folders).

pom.xml (snippets):
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.mypackage.me</groupId>
	<artifactId>myapp</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>myapp</name>
	<url>http://maven.apache.org</url>
	<dependencies>
		<dependency>
......

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<artifactId>maven-compiler-plugin</artifactId>
					<configuration>
						<source>1.5</source>
						<target>1.5</target>
					</configuration>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-jar-plugin</artifactId>
					<configuration>
						<archive>
							<manifest>
								<mainClass>
									com.mypackage.me.ClassWithMainMethod
								</mainClass>
							</manifest>
						</archive>					
						<includes>
							<include>spring-context.xml</include>
						</includes>
						<excludes>
							<exclude>/*.properties</exclude>
						</excludes>					
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>

........

using mvn clean install 

myapp-1.0-SNAPSHOT.jar
   - META-INF
   - spring-context.xml
   - <NO> package folders?

Any advice?
Many thanks..


-- 
View this message in context: http://maven.40175.n5.nabble.com/Maven-create-JAR-tp3300215p3300215.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven create JAR

Posted by Anders Hammar <an...@hammar.net>.
Yes. Did you try removing the "includes" part of you config? You're actually
telling the jar-plugin to only include the spring-context.xml file. No
wonder there are no .class files included.

/Anders

On Fri, Dec 10, 2010 at 14:54, madeOfStarStuff <so...@hotmail.com>wrote:

>
> Thanks for the reply.  The problem is that NO .class files are being
> included
> in the .jar file.
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Maven-create-JAR-tp3300215p3300312.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven create JAR

Posted by madeOfStarStuff <so...@hotmail.com>.
Thanks for the reply.  The problem is that NO .class files are being included
in the .jar file.
-- 
View this message in context: http://maven.40175.n5.nabble.com/Maven-create-JAR-tp3300215p3300312.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Maven create JAR

Posted by Anders Hammar <an...@hammar.net>.
Well, you're only including spring-context.xml with that config so Maven
does what you're telling it to. :-)
I think you would get what you want if you just remove the includes snippet
(and keep the excludes).

/Anders
On Fri, Dec 10, 2010 at 13:18, madeOfStarStuff <so...@hotmail.com>wrote:

>
> Hi, I'm sure this will be simple one...
>
> My pom.xml is configured to create a jar; which is does. However, I've
> added
> some config to inlude and exclude certain files etc.  When I do this, none
> of the class files are added (i.e. package folders).
>
> pom.xml (snippets):
> <project xmlns="http://maven.apache.org/POM/4.0.0"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
>        <modelVersion>4.0.0</modelVersion>
>        <groupId>com.mypackage.me</groupId>
>        <artifactId>myapp</artifactId>
>        <packaging>jar</packaging>
>        <version>1.0-SNAPSHOT</version>
>        <name>myapp</name>
>        <url>http://maven.apache.org</url>
>        <dependencies>
>                <dependency>
> ......
>
>        <build>
>                <pluginManagement>
>                        <plugins>
>                                <plugin>
>
>  <artifactId>maven-compiler-plugin</artifactId>
>                                        <configuration>
>                                                <source>1.5</source>
>                                                <target>1.5</target>
>                                        </configuration>
>                                </plugin>
>                                <plugin>
>
>  <groupId>org.apache.maven.plugins</groupId>
>
>  <artifactId>maven-jar-plugin</artifactId>
>                                        <configuration>
>                                                <archive>
>                                                        <manifest>
>                                                                <mainClass>
>
>  com.mypackage.me.ClassWithMainMethod
>                                                                </mainClass>
>                                                        </manifest>
>                                                </archive>
>                                                <includes>
>
>  <include>spring-context.xml</include>
>                                                </includes>
>                                                <excludes>
>
>  <exclude>/*.properties</exclude>
>                                                </excludes>
>                                        </configuration>
>                                </plugin>
>                        </plugins>
>                </pluginManagement>
>
> ........
>
> using mvn clean install
>
> myapp-1.0-SNAPSHOT.jar
>   - META-INF
>   - spring-context.xml
>   - <NO> package folders?
>
> Any advice?
> Many thanks..
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Maven-create-JAR-tp3300215p3300215.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Maven create JAR

Posted by Wayne Fay <wa...@gmail.com>.
>                            <includes>
>                                    <include>spring-context.xml</include>
>                            </includes>

As Anders has told you repeatedly now, this <include> line in your
config tells Maven to "only include the following file(s) in my jar"
and that is exactly what Maven is doing.

Remove the include, leave only the <excludes>, and your classes should
magically appear in the jar file.

Wayne