org.apache.maven.plugin.changes.ChangesXML Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-changes-plugin Show documentation
Show all versions of maven-changes-plugin Show documentation
Creates a release history for inclusion into the site and assists in generating an announcement mail.
package org.apache.maven.plugin.changes;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
import java.io.File;
import java.io.FileInputStream;
import java.util.Collections;
import java.util.List;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.changes.model.Body;
import org.apache.maven.plugins.changes.model.ChangesDocument;
import org.apache.maven.plugins.changes.model.Properties;
import org.apache.maven.plugins.changes.model.io.xpp3.ChangesXpp3Reader;
import org.codehaus.plexus.util.IOUtil;
/**
* A facade for a changes.xml file.
*
* @version $Id: ChangesXML.java 1579079 2014-03-18 22:57:22Z dennisl $
*/
public class ChangesXML
{
private List releaseList;
private String author;
private String title;
private String authorEmail;
private ChangesDocument changesDocument;
public ChangesXML( File xmlPath, Log log )
{
if ( xmlPath == null || !xmlPath.exists() )
{
log.error( "changes xml file is null or not exists " );
return;
}
FileInputStream fileInputStream = null;
try
{
ChangesXpp3Reader reader = new ChangesXpp3Reader();
fileInputStream = new FileInputStream( xmlPath );
changesDocument = reader.read( fileInputStream, false );
if ( changesDocument == null )
{
log.error( "Cannot build Changes Report from file: " + xmlPath.getPath() );
return;
}
Properties properties = changesDocument.getProperties();
if ( properties != null )
{
if ( properties.getAuthor() != null )
{
this.author = properties.getAuthor().getName();
this.authorEmail = properties.getAuthor().getName();
}
this.title = properties.getTitle();
}
Body body = changesDocument.getBody();
if ( body != null )
{
this.releaseList = body.getReleases();
}
}
catch ( Throwable e )
{
// FIXME throw an Exception ?
log.error( "An error occurred when parsing the changes.xml file: ", e );
}
finally
{
IOUtil.close( fileInputStream );
}
}
public void setAuthor( String author )
{
this.author = author;
}
public String getAuthor()
{
return author;
}
public void setReleaseList( List releaseList )
{
this.releaseList = releaseList;
}
public List getReleaseList()
{
return releaseList == null ? Collections.EMPTY_LIST : releaseList;
}
public void setTitle( String title )
{
this.title = title;
}
public String getTitle()
{
return title;
}
public ChangesDocument getChangesDocument()
{
return changesDocument;
}
public String getAuthorEmail()
{
return authorEmail;
}
public void setAuthorEmail( String authorEmail )
{
this.authorEmail = authorEmail;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy