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...@cqs.ch> on 2003/01/24 14:20:34 UTC

[Proposition] Type Descriptor

I have following proposition.

Currently (I have reported those problems in Jira) there are at least two
know problems with artifact/dependency handling

1. Maven does not support dependencies with different type name and file
extension (e.g. ejb has extension jar)
2. Maven adds to build class only jars

Those problems are related to many arbitrary assumption which are currently
hard coded in Java code

(e.g.: from DependencyClasspathBuilder)

// Only add jar dependencies to the classpath
if ( d.getType().equals( "jar" ) == false )



That's why I think that some way of configuration of those aspects is
needed.

I am proposing following solution:


Maven keeps information about types in following configuration file:


<typeDescriptors>  
 
   <typeDescriptor>
       <name>jar</name>
       <extension>jar</extension>
       <directory>jars</directory>
       <description>Java ARchive (JAR)</description>
       <properties>
         <buildclasspath>true</buildclasspath>      	 
      </properties>
   </typeDescriptor>
   
   
   <typeDescriptor>
      <name>ejb</name>
      <extension>jar</extension>
      <directory>ejbs</directory>
      <description>ejb-jar module of J2EE application</description>
      <properties>
         <buildclasspath>true</buildclasspath>
      </properties>
   </typeDescriptor>
   

   <typeDescriptor>
      <name>war</name>
      <extension>war</extension>
      <directory>wars</directory>
      <description>Web Application Archive (WAR)  module of J2EE
application</description>      
   </typeDescriptor>     
 
  ...   
 </typeDescriptors>

  

After information provided in such config file could be for example used in
following places:

- ArtifactFactory before creating artifact should use it to correctly set
artifact properties
- DependencyClasspathBuilder 
 should check defined artifact property to determine which type of artifacts
should be added to build classpath
- Plugin scripts for deploying  artifacts
- etc...


I have implemented (not so) simple set of classes which provided access to
the information stored in such config files.

I am including following things in zip file 

1. TypeDescriptor, TypeDescriptors, TypeDescriptorFactory classes
2. Project class  - the way I see a possibility to integrate it with
existing Maven classes (the changes are at the very bottom of the file)
3. sample config file:  maven-type-descriptors.xml 
4. sample maven.xml file which shows some use cases of this little library



I have tried to make it compatible with POM inheritance concept and maven
properties processing

So Maven process maven-type-descriptors.xml files in the following order:

The properties files in Maven are processed in the following order: 
*	${maven.home}/bin/maven-type-descriptors
*	${project.parentProject..home}/maven-type-descriptors
*	${project.home}/maven-type-descriptors
*	${user.home}/maven-type-descriptors 


So it is enough for testing to place provided example file in one of those
places.
Normally I think that there will be almost no need to have such complex
mechanism...


I hope that my  code is mostly self explaining.


// I M P O R T A N T:
I have still one implementation problem: 

Somehow I cannot figure out how to force bewixt (via MavenUtils class) to
read my configuration files...
I suppose that for somebody who knows Maven internals and betwixt better
than me it should be question of seconds to fix this problem.
I tried to follow all naming patterns required by betwixt..


If this proposition will be accepted I suppose that next step will be to 
propagate it to ArtifactFactory, Artifact and  DependencyClasspathBuilder 


Then of course I promise to write test cases etc..
Please also provide comments about naming convention for classes, packages
and config file I used. 




Example:

(e.g.: how DependencyClasspathBuilder can then be rewritten)

BEFORE:
// Only add jar dependencies to the classpath
if ( d.getType().equals( "jar" ) == false )


AFTER:

String type=d.getType();
TypeDescriptor typeDescriptor=project.getTypeDesc(type);
String value=typeDescriptor.getProperty("buildclasspath");
if ("true".equals(value))


I think there is a lot of hidden nice features of such config file (maybe
not exactly in the form I have propose):


1. It can be used to create a documentation and explain different twisted
file formats and provide links to their specifications...
2. It can provide an information about mime-type of the artifact...
3 ...


I am waiting for your comments!



Michal

 <<typedescriptor.zip>> 



Re: [Proposition] Type Descriptor

Posted by Jason van Zyl <ja...@zenplex.com>.
On Fri, 2003-01-24 at 08:20, Michal Maczka wrote:
> I have following proposition.
> 
> Currently (I have reported those problems in Jira) there are at least two
> know problems with artifact/dependency handling
> 
> 1. Maven does not support dependencies with different type name and file
> extension (e.g. ejb has extension jar)
> 2. Maven adds to build class only jars
> 
> Those problems are related to many arbitrary assumption which are currently
> hard coded in Java code
> 
> (e.g.: from DependencyClasspathBuilder)
> 
> // Only add jar dependencies to the classpath
> if ( d.getType().equals( "jar" ) == false )
> 
> 
> 
> That's why I think that some way of configuration of those aspects is
> needed.
> 
> I am proposing following solution:

Sorry for not responding earlier. I will take look at this tomorrow
night and see if I can integrate it. Much appreciated!

-- 
jvz.

Jason van Zyl
jason@zenplex.com
http://tambora.zenplex.org

In short, man creates for himself a new religion of a rational
and technical order to justify his work and to be justified in it.
  
  -- Jacques Ellul, The Technological Society