Package org.apache.maven.model

Examples of org.apache.maven.model.License


            }

            List<License> licenses = model.getLicenses();
            if ( licenses.isEmpty() )
            {
                License license = new License();

                getLog().info( "License name is missing, please type the license name:" );
                license.setName( inputHandler.readLine() );
                getLog().info( "License URL is missing, please type the license URL:" );
                license.setUrl( inputHandler.readLine() );
                licenses.add( license );
                rewrite = true;
            }
           
            if ( disableMaterialization )
View Full Code Here


    /**
     * Creates a new license object.
     */
    public License license(String name, String url) {
        License l = new License();
        l.setName(name);
        l.setUrl(url);
        return l;
    }
View Full Code Here

        for ( Iterator it = v3Licenses.iterator(); it.hasNext(); )
        {
            org.apache.maven.model.v300.License v3License =
                (org.apache.maven.model.v300.License) it.next();

            License license = new License();

            license.setName( nullIfEmpty( v3License.getName() ) );

            license.setUrl( nullIfEmpty( v3License.getUrl() ) );

            license.setComments( nullIfEmpty( v3License.getComments() ) );

            licenses.add( license );
        }

        return licenses;
View Full Code Here

        metadata.setDescription(project.getDescription());
        metadata.setCategory(category);

        if (project.getLicenses() != null) {
            for (Object licenseObj : project.getLicenses()) {
                License license = (License) licenseObj;
                LicenseType licenseType = new LicenseType();
                licenseType.setValue(license.getName());
                licenseType.setOsiApproved(osiApproved);
                metadata.getLicense().add(licenseType);
            }
        }
View Full Code Here

            if ( model.getLicenses() != null && model.getLicenses().size() > 0 )
            {
                serializer.writeStartElement( "licenses" );
                for ( Iterator iter = model.getLicenses().iterator(); iter.hasNext(); )
                {
                    License o = (License) iter.next();
                    writeLicense( o, "license", serializer );
                }
                serializer.writeEndElement();
            }
            if ( model.getVersions() != null && model.getVersions().size() > 0 )
View Full Code Here

     * @param element
     */
    private License parseLicense(String tagName, Element element, boolean strict, String encoding)
        throws IOException, DocumentException
    {
        License license = new License();
        license.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        for ( Iterator i = element.nodeIterator(); i.hasNext(); )
        {
            Node node = (Node) i.next();
            if ( node.getNodeType() != Node.ELEMENT_NODE )
            {
            }
            else
            {
                Element childElement = (Element) node;
                if ( childElement.getName().equals( "name" )  )
                {
                    if ( parsed.contains( "name" ) )
                    {
                        throw new DocumentException( "Duplicated tag: '" + element.getName() + "'");
                    }
                    parsed.add( "name" );
                    license.setName( getTrimmedValue( childElement.getText() ) );
                }
                else if ( childElement.getName().equals( "url" )  )
                {
                    if ( parsed.contains( "url" ) )
                    {
                        throw new DocumentException( "Duplicated tag: '" + element.getName() + "'");
                    }
                    parsed.add( "url" );
                    license.setUrl( getTrimmedValue( childElement.getText() ) );
                }
                else if ( childElement.getName().equals( "distribution" )  )
                {
                    if ( parsed.contains( "distribution" ) )
                    {
                        throw new DocumentException( "Duplicated tag: '" + element.getName() + "'");
                    }
                    parsed.add( "distribution" );
                    license.setDistribution( getTrimmedValue( childElement.getText() ) );
                }
                else if ( childElement.getName().equals( "comments" )  )
                {
                    if ( parsed.contains( "comments" ) )
                    {
                        throw new DocumentException( "Duplicated tag: '" + element.getName() + "'");
                    }
                    parsed.add( "comments" );
                    license.setComments( getTrimmedValue( childElement.getText() ) );
                }
                else
                {
                    if ( strict )
                    {
View Full Code Here

     * @param xmlStreamReader
     */
    private License parseLicense(String tagName, XMLStreamReader xmlStreamReader, boolean strict, String encoding)
        throws IOException, XMLStreamException
    {
        License license = new License();
        license.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        while ( xmlStreamReader.nextTag() == XMLStreamConstants.START_ELEMENT )
        {
            if ( xmlStreamReader.getLocalName().equals( "name" )  )
            {
                if ( parsed.contains( "name" ) )
                {
                    throw new XMLStreamException( "Duplicated tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
                }
                parsed.add( "name" );
                license.setName( getTrimmedValue( xmlStreamReader.getElementText()) );
            }
            else if ( xmlStreamReader.getLocalName().equals( "url" )  )
            {
                if ( parsed.contains( "url" ) )
                {
                    throw new XMLStreamException( "Duplicated tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
                }
                parsed.add( "url" );
                license.setUrl( getTrimmedValue( xmlStreamReader.getElementText()) );
            }
            else if ( xmlStreamReader.getLocalName().equals( "distribution" )  )
            {
                if ( parsed.contains( "distribution" ) )
                {
                    throw new XMLStreamException( "Duplicated tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
                }
                parsed.add( "distribution" );
                license.setDistribution( getTrimmedValue( xmlStreamReader.getElementText()) );
            }
            else if ( xmlStreamReader.getLocalName().equals( "comments" )  )
            {
                if ( parsed.contains( "comments" ) )
                {
                    throw new XMLStreamException( "Duplicated tag: '" + xmlStreamReader.getLocalName() + "'", xmlStreamReader.getLocation() );
                }
                parsed.add( "comments" );
                license.setComments( getTrimmedValue( xmlStreamReader.getElementText()) );
            }
            else
            {
                if ( strict )
                {
View Full Code Here

            List<License> licenses = model.getLicenses();
            properties.put( "license.count", Integer.valueOf( licenses.size() ) );
            for ( int i = 0; i < licenses.size(); i++ )
            {
                License license = licenses.get( i );
                properties.put( "license." + i + ".name", license.getName() );
                properties.put( "license." + i + ".url", license.getUrl() );
                properties.put( "license." + i + ".comments", license.getComments() );
                properties.put( "license." + i + ".distribution", license.getDistribution() );
            }

            result.setProperties( properties );

            setArtifactProperties( result, model );
View Full Code Here

     * @param parser
     */
    private License parseLicense(String tagName, XmlPullParser parser, boolean strict, String encoding)
        throws IOException, XmlPullParserException
    {
        License license = new License();
        license.setModelEncoding( encoding );
        java.util.Set parsed = new java.util.HashSet();
        while ( parser.nextTag() == XmlPullParser.START_TAG )
        {
            if ( parser.getName().equals( "name" )  )
            {
                if ( parsed.contains( "name" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "name" );
                license.setName( getTrimmedValue( parser.nextText()) );
            }
            else if ( parser.getName().equals( "url" )  )
            {
                if ( parsed.contains( "url" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "url" );
                license.setUrl( getTrimmedValue( parser.nextText()) );
            }
            else if ( parser.getName().equals( "distribution" )  )
            {
                if ( parsed.contains( "distribution" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "distribution" );
                license.setDistribution( getTrimmedValue( parser.nextText()) );
            }
            else if ( parser.getName().equals( "comments" )  )
            {
                if ( parsed.contains( "comments" ) )
                {
                    throw new XmlPullParserException( "Duplicated tag: '" + parser.getName() + "'", parser, null);
                }
                parsed.add( "comments" );
                license.setComments( getTrimmedValue( parser.nextText()) );
            }
            else
            {
                if ( strict )
                {
View Full Code Here

            {
                Element listElement = element;
                listElement = element.addElement( "licenses" );
                for ( Iterator iter = model.getLicenses().iterator(); iter.hasNext(); )
                {
                    License o = (License) iter.next();
                    writeLicense( o, "license", listElement );
                }
            }
            if ( model.getVersions() != null && model.getVersions().size() > 0 )
            {
View Full Code Here

TOP

Related Classes of org.apache.maven.model.License

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.