You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Brett Porter <br...@apache.org> on 2007/01/07 23:06:32 UTC

Re: svn commit: r493812 - in /maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/writer: ./ WriterUtils.java

Since Milos is a committer, and assuming he wrote the whole file, can  
he commit/give permission to commit the change to the license header?

Either way, this needs the Apache one added to it even if it doesn't  
replace it.

- Brett

On 08/01/2007, at 6:16 AM, jvanzyl@apache.org wrote:

> Author: jvanzyl
> Date: Sun Jan  7 11:16:37 2007
> New Revision: 493812
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=493812
> Log:
> o a little utility using jdom to write out models
>
> Added:
>     maven/components/trunk/maven-embedder/src/main/java/org/apache/ 
> maven/embedder/writer/
>     maven/components/trunk/maven-embedder/src/main/java/org/apache/ 
> maven/embedder/writer/WriterUtils.java   (with props)
>
> Added: maven/components/trunk/maven-embedder/src/main/java/org/ 
> apache/maven/embedder/writer/WriterUtils.java
> URL: http://svn.apache.org/viewvc/maven/components/trunk/maven- 
> embedder/src/main/java/org/apache/maven/embedder/writer/ 
> WriterUtils.java?view=auto&rev=493812
> ====================================================================== 
> ========
> --- maven/components/trunk/maven-embedder/src/main/java/org/apache/ 
> maven/embedder/writer/WriterUtils.java (added)
> +++ maven/components/trunk/maven-embedder/src/main/java/org/apache/ 
> maven/embedder/writer/WriterUtils.java Sun Jan  7 11:16:37 2007
> @@ -0,0 +1,78 @@
> +/*  
> ====================================================================== 
> ====
> + * Copyright 2006 Mevenide Team
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing,  
> software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express  
> or implied.
> + *  See the License for the specific language governing  
> permissions and
> + *  limitations under the License.
> + *  
> ====================================================================== 
> ===
> + */
> +
> +package org.apache.maven.embedder.writer;
> +
> +import org.apache.maven.model.Model;
> +import org.apache.maven.model.io.jdom.MavenJDOMWriter;
> +import org.jdom.Document;
> +import org.jdom.Element;
> +import org.jdom.Namespace;
> +import org.jdom.output.Format;
> +
> +import java.io.IOException;
> +import java.io.Writer;
> +
> +//TODO: turn this into a component
> +
> +/** @author mkleint@codehaus.org */
> +public class WriterUtils
> +{
> +    public static void write( Writer w,
> +                              Model newModel )
> +        throws IOException
> +    {
> +        write( w, newModel, false );
> +    }
> +
> +    public static void write( Writer w,
> +                              Model newModel,
> +                              boolean namespaceDeclaration )
> +        throws IOException
> +    {
> +        Element root = new Element( "project" );
> +
> +        if ( namespaceDeclaration )
> +        {
> +            String modelVersion = newModel.getModelVersion();
> +
> +            Namespace pomNamespace = Namespace.getNamespace( "",  
> "http://maven.apache.org/POM/" + modelVersion );
> +
> +            root.setNamespace( pomNamespace );
> +
> +            Namespace xsiNamespace = Namespace.getNamespace 
> ( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
> +
> +            root.addNamespaceDeclaration( xsiNamespace );
> +
> +            if ( root.getAttribute( "schemaLocation",  
> xsiNamespace ) == null )
> +            {
> +                root.setAttribute( "schemaLocation", "http:// 
> maven.apache.org/POM/" + modelVersion +
> +                    " http://maven.apache.org/maven-v" +  
> modelVersion.replace( '.', '_' ) + ".xsd", xsiNamespace );
> +            }
> +        }
> +
> +        Document doc = new Document( root );
> +
> +        MavenJDOMWriter writer = new MavenJDOMWriter();
> +
> +        String encoding = newModel.getModelEncoding() != null ?  
> newModel.getModelEncoding() : "UTF-8";
> +
> +        Format format = Format.getPrettyFormat().setEncoding 
> ( encoding );
> +
> +        writer.write( newModel, doc, w, format );
> +    }
> +}
>
> Propchange: maven/components/trunk/maven-embedder/src/main/java/org/ 
> apache/maven/embedder/writer/WriterUtils.java
> ---------------------------------------------------------------------- 
> --------
>     svn:eol-style = native
>
> Propchange: maven/components/trunk/maven-embedder/src/main/java/org/ 
> apache/maven/embedder/writer/WriterUtils.java
> ---------------------------------------------------------------------- 
> --------
>     svn:keywords = "Author Date Id Revision"
>

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