You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Michal Maczka <mm...@interia.pl> on 2003/01/09 22:32:08 UTC

Artifact/Dependency - proposition of refactoring

As I have signaled sometimes ago I have encountered some problems related
to ejb dependency handling which are caused by the current limitations of
Dependency/Artifact model.

To remind:

In current state of Maven I cannot simply do something like:

<dependency>
   <groupId>mygroup</groupId>
   <id>myejbjar</id>
   <type>ejb</type>
   <version>1.0.0</version>
</dependency>


because Maven per default use type tag for computing two things:

1. directory name in repository
2. extension of the dependency file

In case of ejb artifact the extension of the file is different than ".ejb".
It is ".jar"

Secondly dependencies of type 'ejb' are not visible in the java compilation
process as they are not added to
compilation classpath. Currently the process of computing BuildClasspath is
rather dirty.
Maven needs to be easy to instruct which types of  artifacts should be added
to build classpath. And this IMHO
should be achieve differently than it is now (those types are simple
hardcoded)


To resolve above problems and to also clean some other things I am proposing
following changes


1.  Dependency changes (will affect POM):


 - and new property field called 'file' which will replace in future
property jar. Temporary both <jar> and <file>
   tag would be supported in POM
  ( BTW is promised auto update of POM files working?)


2. Artifact

 - add new  field called 'ext' - which will denote the extension of the
artifact file.
   This is needed as not always dependency type is the same as extension of
the file to which it points.
   e.g. dependency of type ejb cannot be processed easily in current model.

3. ArtifactFactory changes (more controversial)

I think that DefaultArtifactFactory is not smart enough to solve the neither
the artifact naming problem nor the compilation
path problem I described.


I think that it will be nice to have some configuration file for
org.apache.maven.repository.ArtifactFactory
I saw Jason's comments in DefaultArtifactFactory. I think that it will be
better to use XML-based config file
than .properties file.


I see a need to include at least the following information in it

<types>
   <type>
    <name>jar<type>
    <ext>jar<ext>
    <dir>jars<dir>
    <description>Java Archive</description>
    <add_to_build_classpath>true</add_to_build_classpath> <!-- this solve
build classpath problem -->
  </type>
  <type>
    <name>ejb-jar<type>
    <ext>jar<ext>
    <dir>ejbs<dir>
    <description>J2EE ejb-jar module</description>
    <add_to_build_classpath>true</add_to_build_classpath>
  </type>
  <type>
    <name>ejb<type>
    <!-- this solves the problem I have mentioned above: ext!=dir -->
    <ext>jar<ext>
    <dir>ejbs<dir>
    <description>J2EE ejb-jar module</description>
    <add_to_build_classpath>true</add_to_build_classpath>
  </type>
  <type>
    <name>war<type>
    <ext>war<ext>
    <dir>wars<dir>
    <description>J2EE Web Application Archive</description>
  </type>
  <type>
    <name>ear<type>
    <ext>ear<ext>
    <dir>ears<dir>
    <description>J2EE Enterprise Archive</description>
  </type>
  <type>
    <name>dtd<type>
    <ext>dtd<ext>
    <dir>dtds<dir>
    <description>Document Type Definition(markup languages)</description>
  </type>
  <type>
    <name>properties<type>
    <ext>properties<ext>
    <!-- this is tricky one: 'couse normal Maven's mechanism will currently
compute the name "propertiess"
       Also there is sometime more complicated way of creating plural form
of some nouns in English.
       Maybe there will be case like that?
    -->
    <dir>properties<dir>
    <description>Java Properties file</description>
  </type>
  <type>
    <name>xsd<type>
    <ext>xsd<ext>
    <dir>xsds<dir>
    <description>XML Schema Definition</description>
  </type>


    ....

<types>


I hope that this example is rather self explaining after introducing the
problems which lead me to this request for changes..
Of course I say noting about name of the tags nor XML grammar if such
mechanism will be implemented.
That is just kind of brain storm idea from my side...


I know that new refactoring of dependencies etc.. is currently discussed. I
just hope that my ideas can help
in this process.

regards

Michal Maczka




----------------------------------------------------------------------
Rozrywkowe info w portalu INTERIA.PL >>> http://link.interia.pl/f16b8