You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David Weintraub <qa...@gmail.com> on 2009/06/22 22:42:11 UTC

Maven with Hibernate/Multiple POM files

I have a project (it's actually a sub-project of another project, so
it will get interesting).

We build three items: base.jar, base-ui.jar, and base-hib.har. These
each are in their own sub-directory, and I can treat them like
projects. I was able to get the whole thing working. However, the
base-hib.har uses Hibernate, and I couldn't find any information on
setting up a project that uses Hibernate.

I was able to generate a Hibernate pom.xml using archetype:generate,
but it seems like that the POM requires a service file to be named
"jboss-service.xml". Unfortunately, ours is named
hibernate-service.xml, and I couldn't find anyway to configure this in
the POM.

Another question: I build the base.jar file, and the other two
projects depend upon that file. I've setup the POMs to show this
dependency: Everything builds, but when I run analyze:dependency, it
tells me it is missing base.jar

-- 
David Weintraub
qazwart@gmail.com

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


Re: Maven with Hibernate/Multiple POM files

Posted by Jörg Schaible <jo...@gmx.de>.
Hi David,

David Weintraub wrote at Donnerstag, 25. Juni 2009 17:34:

>> 1/ A POM is not a programming language, but a project description. It is
>> pointless to define the properties section in the top of the file in the
>> hope that Maven sees the values first before you use them. You can
>> call "mvn help:effective-pom" to see what Maven actually uses for the
>> project description in the end.
> 
> It could be that I simply don't understand how to do something. We
> have a continuous build system, and label each of our builds with a
> build number. We like that build number to part of the maven artifact
> itself. For example, aim-2.1.2-D-32-bin.tar.gz where 2.1.2-D-32 is our
> build number.
> 
> However, there is no need to put these builds into our Maven
> repository since our continuous build system makes them available and
> manages them. Otherwise, I would have to do a constant purge our our
> Maven repository since we can do 10 to 20 builds each day.
> 
> This is why I have the product's version as a property. I can pass it
> into the pom when a build is done. At the same time, I need to allow
> developers to run the builds themselves, and not have
> aim-${aim.version}-bin.tar.gz as the name of the maven artifact. In
> order to avoid this, I put the property inside of the POM. I could put
> this anywhere directly under the <project/>, but putting it at top
> allows the developers to easily find it when they do want to change
> the default (such as when we start work on version 2.1.3).
> 
> So, what is the correct way to set my projects in order to be able to
> have a default version number, yet allow me to override it on the
> command line?

At least I can now understand why you try to do this and that you actually
understood, that declaring the property right in the top does not change
anything.

However, with using a property for the parent's version you're more or less
building on undefined Maven behavior. Main reason is that Maven has to
resolve the parent before it can generate the resulting project model.

Did you had a look at the buildnumber plugin instead? It might help you in
this case.

> That also doesn't cover my other problem: I am using
> net.sf.maven-har:maven-har-plugin which requires me to have my service
> file called jboss-service.xml living in the resource's META-INF
> directory. Unfortunately, our service file is called
> hibernate-service.xml.
> 
> Is it possible to somehow redefine the name of this file in your
> pom.xml? If I was writing this code from scratch, I would simply use
> the default name. But, I have to make sure that the structure of my
> Maven artifact matches the output of our current build artifact.
> 
> Where can I at least find documentation on this plugin? I got the
> basic POM structure by doing a mvn archetype:generate and requesting a
> har project.

This plugin is obviously developed by an independent project at SourceForge,
you will have to ask the developers there.

- Jörg

> 



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


Re: Maven with Hibernate/Multiple POM files

Posted by David Weintraub <qa...@gmail.com>.
> 1/ A POM is not a programming language, but a project description. It is
> pointless to define the properties section in the top of the file in the
> hope that Maven sees the values first before you use them. You can
> call "mvn help:effective-pom" to see what Maven actually uses for the
> project description in the end.

It could be that I simply don't understand how to do something. We
have a continuous build system, and label each of our builds with a
build number. We like that build number to part of the maven artifact
itself. For example, aim-2.1.2-D-32-bin.tar.gz where 2.1.2-D-32 is our
build number.

However, there is no need to put these builds into our Maven
repository since our continuous build system makes them available and
manages them. Otherwise, I would have to do a constant purge our our
Maven repository since we can do 10 to 20 builds each day.

This is why I have the product's version as a property. I can pass it
into the pom when a build is done. At the same time, I need to allow
developers to run the builds themselves, and not have
aim-${aim.version}-bin.tar.gz as the name of the maven artifact. In
order to avoid this, I put the property inside of the POM. I could put
this anywhere directly under the <project/>, but putting it at top
allows the developers to easily find it when they do want to change
the default (such as when we start work on version 2.1.3).

So, what is the correct way to set my projects in order to be able to
have a default version number, yet allow me to override it on the
command line?

That also doesn't cover my other problem: I am using
net.sf.maven-har:maven-har-plugin which requires me to have my service
file called jboss-service.xml living in the resource's META-INF
directory. Unfortunately, our service file is called
hibernate-service.xml.

Is it possible to somehow redefine the name of this file in your
pom.xml? If I was writing this code from scratch, I would simply use
the default name. But, I have to make sure that the structure of my
Maven artifact matches the output of our current build artifact.

Where can I at least find documentation on this plugin? I got the
basic POM structure by doing a mvn archetype:generate and requesting a
har project.

-- 
David Weintraub
qazwart@gmail.com

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


Re: Maven with Hibernate/Multiple POM files

Posted by Jörg Schaible <jo...@gmx.de>.
Hi David,

[sorting the mail]

>> > Another question: I build the base.jar file, and the other two
>> > projects depend upon that file. I've setup the POMs to show this
>> > dependency: Everything builds, but when I run analyze:dependency, it
>> > tells me it is missing base.jar

[snip]

> The "base" directory's POM.xml:
> 
> <project>
>    <modelVersion>4.0.0</modelVersion>
>    <properties>
>            <base.version>2.1.2-SNAPSHOT</base.version>
>    </properties>
>    <groupId>com.solbright</groupId>
>    <version>${base.version}</version>
>    <artifactId>base</artifactId>

[snip]

> The JAR directory pom:
>
> <project>
>    <modelVersion>4.0.0</modelVersion>
>    <groupId>com.solbright.base</groupId>
>    <artifactId>jar</artifactId>
>    <packaging>jar</packaging>
>    <name>jar</name>
>    <version>${base.version}</version>
>    <parent>
>       <groupId>com.solbright</groupId>
>       <artifactId>base</artifactId>
>           <version>${base.version}</version>
>    </parent>

[snip]

> And, finally the HAR pom.xml
> 
> <project>
>    <modelVersion>4.0.0</modelVersion>
>    <groupId>com.solbright.base</groupId>
>    <artifactId>har</artifactId>
>    <packaging>har</packaging>
>    <name>har</name>
>    <version>${base.version}</version>
>    <parent>
>       <groupId>com.solbright</groupId>
>       <artifactId>base</artifactId>
>           <version>${base.version}</version>
>    </parent>

[snip]

>         <dependencies>
>                 <dependency>
>                         <groupId>com.solbright.base</groupId>
>                         <artifactId>jar</artifactId>
>                         <version>${base.version}</version>
>                 </dependency>
>                 <dependency>
>                         <groupId>org.hibernate</groupId>
>                         <artifactId>hibernate</artifactId>
>                         <version>3.1.3</version>
>                 </dependency>
>                 ...
>         </dependencies>
> </project>

1/ A POM is not a programming language, but a project description. It is
pointless to define the properties section in the top of the file in the
hope that Maven sees the values first before you use them. You can
call "mvn help:effective-pom" to see what Maven actually uses for the
project description in the end.

2/ "base.version" is not defined in your submodules if you build from there.
The dependency plugin simply cannot find the parent of your "jar" artifact.

So, stop using properties in the parent section, actually you don't have to
use properties for your versions at all. Use the real version always for
the parent's version and the artifact's version (they're updated by the
release plugin automatically). Define in the parent a depMgmnt section for
the dependencies used by all your modules and declare the dependencies
without version at all.

- Jörg


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


Re: Maven with Hibernate/Multiple POM files

Posted by David Weintraub <qa...@gmail.com>.
The "base" directory's POM.xml:

<project>
   <modelVersion>4.0.0</modelVersion>
   <properties>
           <base.version>2.1.2-SNAPSHOT</base.version>
   </properties>
   <groupId>com.solbright</groupId>
   <version>${base.version}</version>
   <artifactId>base</artifactId>
   <packaging>pom</packaging>
   <name>base</name>
   <modules>
      <module>jar</module>
          <module>servlet</module>
          <module>har</module>
   </modules>
   <dependencyManagement>
      <dependencies>
         <dependency>
            <groupId>com.solbright.base</groupId>
            <artifactId>jar</artifactId>
                        <version>${base.version}</version>
                        <type>jar</type>
         </dependency>
                 <dependency>
                         <groupId>com.solbright.base</groupId>
                         <artifactId>servlet</artifactId>
                         <version>${base.version}</version>
                         <type>jar</type>
                 </dependency>
                 <dependency>
                         <groupId>com.solbright.base</groupId>
                         <artifactId>har</artifactId>
                         <version>${base.version}</version>
                         <type>har</type>
                 </dependency>
      </dependencies>
   </dependencyManagement>
</project>

The JAR directory pom:
<project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.solbright.base</groupId>
   <artifactId>jar</artifactId>
   <packaging>jar</packaging>
   <name>jar</name>
   <version>${base.version}</version>
   <parent>
      <groupId>com.solbright</groupId>
      <artifactId>base</artifactId>
          <version>${base.version}</version>
   </parent>
        <build>
                <finalName>base</finalName>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <configuration>
                                        <archive>
                                                <manifest>

<addClasspath>true</addClasspath>
                                                </manifest>
                                        </archive>
                                </configuration>
                        </plugin>
                </plugins>
        </build>
        <dependencies>
                ...
        </dependencies>

And, finally the HAR pom.xml

<project>
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.solbright.base</groupId>
   <artifactId>har</artifactId>
   <packaging>har</packaging>
   <name>har</name>
   <version>${base.version}</version>
   <parent>
      <groupId>com.solbright</groupId>
      <artifactId>base</artifactId>
          <version>${base.version}</version>
   </parent>
        <build>
                <finalName>base-hib</finalName>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <configuration>
                                        <archive>
                                                <manifest>

<addClasspath>true</addClasspath>
                                                </manifest>
                                        </archive>
                                </configuration>
                        </plugin>
                        <plugin>
                                <groupId>net.sf.maven-har</groupId>
                                <artifactId>maven-har-plugin</artifactId>
                                <version>0.9</version>
                                <extensions>true</extensions>
                        </plugin>
                </plugins>
        </build>
        <dependencies>
                <dependency>
                        <groupId>com.solbright.base</groupId>
                        <artifactId>jar</artifactId>
                        <version>${base.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate</artifactId>
                        <version>3.1.3</version>
                </dependency>
                ...
        </dependencies>
</project>

On Wed, Jun 24, 2009 at 7:36 AM, Baptiste MATHUS <ml...@batmat.net> wrote:
>
> Well, could you give us at least an excerpt of your pom?
> I'm guessing you want to use some jar and didn't acknowledge the local maven
> repository existence, but I might be wrong.
> In fact you seem to be trying to directory use some given jar that's been
> produced by another projet.
>
> But this is all suppositions and I might be wrong, please let us see your
> poms.
>
> Cheers.
>
> 2009/6/22 David Weintraub <qa...@gmail.com>
>
> > I have a project (it's actually a sub-project of another project, so
> > it will get interesting).
> >
> > We build three items: base.jar, base-ui.jar, and base-hib.har. These
> > each are in their own sub-directory, and I can treat them like
> > projects. I was able to get the whole thing working. However, the
> > base-hib.har uses Hibernate, and I couldn't find any information on
> > setting up a project that uses Hibernate.
> >
> > I was able to generate a Hibernate pom.xml using archetype:generate,
> > but it seems like that the POM requires a service file to be named
> > "jboss-service.xml". Unfortunately, ours is named
> > hibernate-service.xml, and I couldn't find anyway to configure this in
> > the POM.
> >
> > Another question: I build the base.jar file, and the other two
> > projects depend upon that file. I've setup the POMs to show this
> > dependency: Everything builds, but when I run analyze:dependency, it
> > tells me it is missing base.jar
> >
> > --
> > David Weintraub
> > qazwart@gmail.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Baptiste <Batmat> MATHUS - http://batmat.net
> Sauvez un arbre,
> Mangez un castor !



--
David Weintraub
qazwart@gmail.com

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


Re: Maven with Hibernate/Multiple POM files

Posted by Baptiste MATHUS <ml...@batmat.net>.
Well, could you give us at least an excerpt of your pom?
I'm guessing you want to use some jar and didn't acknowledge the local maven
repository existence, but I might be wrong.
In fact you seem to be trying to directory use some given jar that's been
produced by another projet.

But this is all suppositions and I might be wrong, please let us see your
poms.

Cheers.

2009/6/22 David Weintraub <qa...@gmail.com>

> I have a project (it's actually a sub-project of another project, so
> it will get interesting).
>
> We build three items: base.jar, base-ui.jar, and base-hib.har. These
> each are in their own sub-directory, and I can treat them like
> projects. I was able to get the whole thing working. However, the
> base-hib.har uses Hibernate, and I couldn't find any information on
> setting up a project that uses Hibernate.
>
> I was able to generate a Hibernate pom.xml using archetype:generate,
> but it seems like that the POM requires a service file to be named
> "jboss-service.xml". Unfortunately, ours is named
> hibernate-service.xml, and I couldn't find anyway to configure this in
> the POM.
>
> Another question: I build the base.jar file, and the other two
> projects depend upon that file. I've setup the POMs to show this
> dependency: Everything builds, but when I run analyze:dependency, it
> tells me it is missing base.jar
>
> --
> David Weintraub
> qazwart@gmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !