You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Marcus Padberg <ma...@dco-gmbh.de> on 2008/11/24 12:11:40 UTC

[Fwd: Problem Eclipse-Plugin v2.5.1 while create MyEclipse EJB project]

-- 
DCO GmbH
Stockholmer Alle 30c
44269 Dortmund

Fon: +(49) 231 477766-60
Fax: +(49) 231 477766-80

Geschäftsführer: Uwe Falkenberg, Walter Dilba
Eingetragen Amtsgericht Dortmund HRB 21208
USt.-ID: DE 256 202 508


Re: [Fwd: Problem Eclipse-Plugin v2.5.1 while create MyEclipse EJB project]

Posted by Arnaud HERITIER <ah...@gmail.com>.
Please open an issue here
http://jira.codehaus.org/browse/MECLIPSE

Without it we'll certainly forgot your patch.
It will help if you deliver also an integration test with a maven project
and what you expect in eclipse config files.

Arnaud


On Mon, Nov 24, 2008 at 12:11 PM, Marcus Padberg <marcus.padberg@dco-gmbh.de
> wrote:

>
> --
> DCO GmbH
> Stockholmer Alle 30c
> 44269 Dortmund
>
> Fon: +(49) 231 477766-60
> Fax: +(49) 231 477766-80
>
> Geschäftsführer: Uwe Falkenberg, Walter Dilba
> Eingetragen Amtsgericht Dortmund HRB 21208
> USt.-ID: DE 256 202 508
>
>
> Hello,
>
> we evaluating MyEclipse (v6.5) as our new development tool. Actual we found
> a problem while creating a EJB project. If we try it some required
> parameters in .mymetadata are missing. Please add this to the next version
> of MyEclipseMetadataWriter.write() at line 103 to generate right code:
>
>       if ( Constants.PROJECT_PACKAGING_EJB.equalsIgnoreCase( packaging ) )
>       {
>           writer.addAttribute( MYECLIPSE_METADATA_PROJECT_J2EE_SPEC,
> getJeeVersion() );
>           // TODO : use maven final name
>           writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ARCHIVE,
> config.getEclipseProjectName() + ".jar" );
>       }
>
> Best regards
> Marcus Padberg
>
> P.S.
> Attached our POM and a modified MyEclipseMetadataWriter which works fine.
>
> --
> DCO GmbH
> Stockholmer Alle 30c
> 44269 Dortmund
>
> Fon: +(49) 231 477766-60
> Fax: +(49) 231 477766-80
>
> Geschäftsführer: Uwe Falkenberg, Walter Dilba
> Eingetragen Amtsgericht Dortmund HRB 21208
> USt.-ID: DE 256 202 508
>
>
> package org.apache.maven.plugin.eclipse.writers.myeclipse;
>
> import java.io.File;
> import java.io.FileWriter;
> import java.io.IOException;
>
> import org.apache.maven.plugin.MojoExecutionException;
> import org.apache.maven.plugin.eclipse.Constants;
> import org.apache.maven.plugin.eclipse.Messages;
> import org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter;
> import org.apache.maven.plugin.ide.IdeUtils;
> import org.apache.maven.plugin.ide.JeeDescriptor;
> import org.apache.maven.plugin.ide.JeeUtils;
> import org.codehaus.plexus.util.IOUtil;
> import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
> import org.codehaus.plexus.util.xml.XMLWriter;
>
> /**
>  * MyEclipse .mymetadata configuration file writer
>  *
>  * @author Olivier Jacob
>  */
> public class MyEclipseMetadataWriter
>    extends AbstractEclipseWriter
> {
>
>    private static final String MYECLIPSE_MYMETADATA_FILENAME =
> ".mymetadata";
>
>    private static final String MYECLIPSE_METADATA_PROJECT =
> "project-module";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_TYPE = "type";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_NAME = "name";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_ID = "id";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_CONTEXT_ROOT =
> "context-root";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_J2EE_SPEC =
> "j2ee-spec";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_ARCHIVE =
> "archive";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_TYPE_WAR = "WEB";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_TYPE_EAR = "EAR";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_TYPE_EJB = "EJB";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_ATTRIBUTES =
> "attributes";
>
>    private static final String MYECLIPSE_METADATA_PROJECT_ATTRIBUTE =
> "attribute";
>
>    /**
>     * Writer entry point
>     *
>     * @throws MojoExecutionException
>     */
>    public void write()
>        throws MojoExecutionException
>    {
>        String packaging = config.getProject().getPackaging();
>
>        if ( !Constants.PROJECT_PACKAGING_EAR.equalsIgnoreCase( packaging )
> &&
>            !Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( packaging )
> &&
>            !Constants.PROJECT_PACKAGING_EJB.equalsIgnoreCase( packaging ) )
>        {
>            return;
>        }
>
>        FileWriter w;
>
>        try
>        {
>            w = new FileWriter( new File(
> config.getEclipseProjectDirectory(), MYECLIPSE_MYMETADATA_FILENAME ) );
>        }
>        catch ( IOException ex )
>        {
>            throw new MojoExecutionException( Messages.getString(
> "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
>        }
>
>        XMLWriter writer = new PrettyPrintXMLWriter( w, "UTF-8", null );
>
>        writer.startElement( MYECLIPSE_METADATA_PROJECT );
>        writer.addAttribute( MYECLIPSE_METADATA_PROJECT_TYPE,
> getMyEclipseProjectType( packaging ) );
>        writer.addAttribute( MYECLIPSE_METADATA_PROJECT_NAME,
> config.getEclipseProjectName() );
>        writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ID,
> config.getEclipseProjectName() );
>
>        if ( Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( packaging ) )
>        {
>            // Find web application context root from maven-war-plugin
> configuration.
>            // ArtifactId is used as the default value
>            String warContextRoot =
>                IdeUtils.getPluginSetting( config.getProject(),
> JeeUtils.ARTIFACT_MAVEN_WAR_PLUGIN, "warContextRoot",//$NON-NLS-1$
>                                           "/" +
> config.getProject().getArtifactId() );
>
>            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_CONTEXT_ROOT,
> warContextRoot );
>
>            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_J2EE_SPEC,
> getJeeVersion() );
>            // TODO : use maven final name
>            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ARCHIVE,
> config.getEclipseProjectName() + ".war" );
>        }
>
>        if ( Constants.PROJECT_PACKAGING_EJB.equalsIgnoreCase( packaging ) )
>        {
>            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_J2EE_SPEC,
> getJeeVersion() );
>            // TODO : use maven final name
>            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ARCHIVE,
> config.getEclipseProjectName() + ".jar" );
>        }
>
>        if ( Constants.PROJECT_PACKAGING_EAR.equalsIgnoreCase( packaging ) )
>        {
>            // TODO : use maven final name
>            writer.addAttribute( MYECLIPSE_METADATA_PROJECT_ARCHIVE,
> config.getEclipseProjectName() + ".ear" );
>        }
>
>        writer.startElement( MYECLIPSE_METADATA_PROJECT_ATTRIBUTES );
>        if ( Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( packaging ) )
>        {
>            writer.startElement( MYECLIPSE_METADATA_PROJECT_ATTRIBUTE );
>            writer.addAttribute( "name", "webrootdir" );
>            // TODO : retrieve this from project configuration
>            writer.addAttribute( "value", "src/main/webapp" );
>            writer.endElement();
>        }
>        // Close <attributes>
>        writer.endElement();
>
>        // Close <project-module>
>        writer.endElement();
>
>        IOUtil.close( w );
>    }
>
>    /**
>     * @param packaging maven project packaging
>     * @return MyEclipse project type (EAR, WAR, EJB)
>     */
>    private String getMyEclipseProjectType( String packaging )
>    {
>        if ( Constants.PROJECT_PACKAGING_WAR.equalsIgnoreCase( packaging ) )
>        {
>            return MYECLIPSE_METADATA_PROJECT_TYPE_WAR;
>        }
>        if ( Constants.PROJECT_PACKAGING_EAR.equalsIgnoreCase( packaging ) )
>        {
>            return MYECLIPSE_METADATA_PROJECT_TYPE_EAR;
>        }
>        if ( Constants.PROJECT_PACKAGING_EJB.equalsIgnoreCase( packaging ) )
>        {
>            return MYECLIPSE_METADATA_PROJECT_TYPE_EJB;
>        }
>        // Should never be reached
>        return null;
>    }
>
>    /**
>     * Find JEE version from the project dependencies : find version from
> 'j2ee.jar' artifact or from 'servlet-api'
>     *
>     * @return the JEE version for the project (1.2, 1.3, 1.4, 1.5)
>     * @see
> org.apache.maven.plugin.ide.JeeUtils#resolveJeeVersion(org.apache.maven.project.MavenProject)
>     */
>    private String getJeeVersion()
>    {
>        String jeeVersion =
>            JeeUtils.getJeeDescriptorFromServletVersion(
> JeeUtils.resolveServletVersion( config.getProject() ) ).getJeeVersion();
>
>        if ( jeeVersion == null )
>        {
>            return JeeDescriptor.JEE_1_4;
>        }
>
>        return jeeVersion;
>    }
> }
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>



-- 
..........................................................
Arnaud HERITIER
12 guidelines to boost your productivity with a Java software factory -
http://tinyurl.com/56s9tw
..........................................................
OCTO Technology - aheritier AT octo DOT com
www.octo.com | blog.octo.com
..........................................................
ASF - aheritier AT apache DOT org
www.apache.org | maven.apache.org
...........................................................