remoteRepositories, ArtifactRepository localRepository )
{
if ( Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) )
{
return null;
}
Artifact copyArtifact = ArtifactUtils.copyArtifact( artifact );
if ( !"pom".equals( copyArtifact.getType() ) )
{
copyArtifact =
factory.createProjectArtifact( copyArtifact.getGroupId(), copyArtifact.getArtifactId(),
copyArtifact.getVersion(), copyArtifact.getScope() );
}
try
{
MavenProject pluginProject =
mavenProjectBuilder.buildFromRepository( copyArtifact,
remoteRepositories == null ? Collections.EMPTY_LIST
: remoteRepositories, localRepository );
if ( isArtifactUrlValid( pluginProject.getUrl() ) )
{
return pluginProject.getUrl();
}
return null;
}
catch ( ProjectBuildingException e )
{
return null;
}
}
/**
* @param artifactId not null
* @param link could be null
* @return the artifactId cell with or without a link pattern
* @see AbstractMavenReportRenderer#linkPatternedText(String)
*/
public static String getArtifactIdCell( String artifactId, String link )
{
if ( StringUtils.isEmpty( link ) )
{
return artifactId;
}
return "{" + artifactId + "," + link + "}";
}
/**
* @param url not null
* @return true
if the url is valid, false
otherwise.
*/
public static boolean isArtifactUrlValid( String url )
{
if ( StringUtils.isEmpty( url ) )
{
return false;
}
return URL_VALIDATOR.isValid( url );
}
/**
* @param url not null
* @param project not null
* @param settings not null
* @return the url connection with auth if required. Don't check the certificate if SSL scheme.
* @throws IOException if any
*/
private static URLConnection getURLConnection( URL url, MavenProject project, Settings settings )
throws IOException
{
URLConnection conn = url.openConnection();
conn.setConnectTimeout( TIMEOUT );
conn.setReadTimeout( TIMEOUT );
// conn authorization
if ( settings.getServers() != null
&& !settings.getServers().isEmpty()
&& project != null
&& project.getDistributionManagement() != null
&& ( project.getDistributionManagement().getRepository() != null || project.getDistributionManagement().getSnapshotRepository() != null )
&& ( StringUtils.isNotEmpty( project.getDistributionManagement().getRepository().getUrl() ) || StringUtils.isNotEmpty( project.getDistributionManagement().getSnapshotRepository().getUrl() ) ) )
{
Server server = null;
if ( url.toString().contains( project.getDistributionManagement().getRepository().getUrl() ) )
{
server = settings.getServer( project.getDistributionManagement().getRepository().getId() );
}
if ( server == null
&& url.toString().contains( project.getDistributionManagement().getSnapshotRepository().getUrl() ) )
{
server = settings.getServer( project.getDistributionManagement().getSnapshotRepository().getId() );
}
if ( server != null && StringUtils.isNotEmpty( server.getUsername() )
&& StringUtils.isNotEmpty( server.getPassword() ) )
{
String up = server.getUsername().trim() + ":" + server.getPassword().trim();
String upEncoded = new String( Base64.encodeBase64Chunked( up.getBytes() ) ).trim();
conn.setRequestProperty( "Authorization", "Basic " + upEncoded );
}
}
if ( conn instanceof HttpsURLConnection )
{
HostnameVerifier hostnameverifier = new HostnameVerifier()
{
/** {@inheritDoc} */
public boolean verify( String urlHostName, SSLSession session )
{
return true;
}
};
( (HttpsURLConnection) conn ).setHostnameVerifier( hostnameverifier );
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager()
{
/** {@inheritDoc} */
public void checkClientTrusted( final X509Certificate[] chain, final String authType )
{
}
/** {@inheritDoc} */
public void checkServerTrusted( final X509Certificate[] chain, final String authType )
{
}
/** {@inheritDoc} */
public X509Certificate[] getAcceptedIssuers()
{
return null;
}
} };
try
{
SSLContext sslContext = SSLContext.getInstance( "SSL" );
sslContext.init( null, trustAllCerts, new SecureRandom() );
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
( (HttpsURLConnection) conn ).setSSLSocketFactory( sslSocketFactory );
}
catch ( NoSuchAlgorithmException e1 )
{
// ignore
}
catch ( KeyManagementException e )
{
// ignore
}
}
return conn;
}
public static boolean isNumber( String str )
{
if ( str.startsWith( "+" ) )
{
str = str.substring( 1 );
}
return NumberUtils.isNumber( str );
}
public static float toFloat( String str, float defaultValue )
{
if ( str.startsWith( "+" ) )
{
str = str.substring( 1 );
}
return NumberUtils.toFloat( str, defaultValue );
}
}
ProjectSummaryReport.java 0000664 0000000 0000000 00000023725 11634435442 0036444 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo package org.apache.maven.report.projectinfo;
/*
* 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 org.apache.maven.doxia.sink.Sink;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Organization;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
/**
* Generates the project information reports summary.
*
* @author Edwin Punzalan
* @version $Id: ProjectSummaryReport.java 1049441 2010-12-15 07:05:00Z ltheussl $
* @since 2.0
* @goal summary
* @plexus.component
*/
public class ProjectSummaryReport
extends AbstractProjectInfoReport
{
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@Override
protected void executeReport( Locale locale )
throws MavenReportException
{
new ProjectSummaryRenderer( getSink(), locale ).render();
}
/** {@inheritDoc} */
public String getOutputName()
{
return "project-summary";
}
@Override
protected String getI18Nsection()
{
return "summary";
}
// ----------------------------------------------------------------------
// Private
// ----------------------------------------------------------------------
/**
* Internal renderer class
*/
private class ProjectSummaryRenderer
extends AbstractProjectInfoRenderer
{
ProjectSummaryRenderer( Sink sink, Locale locale )
{
super( sink, getI18N( locale ), locale );
}
@Override
protected String getI18Nsection()
{
return "summary";
}
@Override
protected void renderBody()
{
startSection( getTitle() );
// general information sub-section
startSection( getI18nString( "general.title" ) );
startTable();
tableHeader( new String[] { getI18nString( "field" ), getI18nString( "value" ) } );
tableRow( new String[] { getI18nString( "general.name" ), project.getName() } );
tableRow( new String[] { getI18nString( "general.description" ), project.getDescription() } );
tableRowWithLink( new String[] { getI18nString( "general.homepage" ), project.getUrl() } );
endTable();
endSection();
// organization sub-section
startSection( getI18nString( "organization.title" ) );
Organization organization = project.getOrganization();
if ( organization == null )
{
paragraph( getI18nString( "noorganization" ) );
}
else
{
startTable();
tableHeader( new String[] { getI18nString( "field" ), getI18nString( "value" ) } );
tableRow( new String[] { getI18nString( "organization.name" ), organization.getName() } );
tableRowWithLink( new String[] { getI18nString( "organization.url" ), organization.getUrl() } );
endTable();
}
endSection();
// build section
startSection( getI18nString( "build.title" ) );
startTable();
tableHeader( new String[] { getI18nString( "field" ), getI18nString( "value" ) } );
tableRow( new String[] { getI18nString( "build.groupid" ), project.getGroupId() } );
tableRow( new String[] { getI18nString( "build.artifactid" ), project.getArtifactId() } );
tableRow( new String[] { getI18nString( "build.version" ), project.getVersion() } );
tableRow( new String[] { getI18nString( "build.type" ), project.getPackaging() } );
if ( isJavaProject( project ) )
{
tableRow( new String[] { getI18nString( "build.jdk" ), getMinimumJavaVersion() } );
}
endTable();
endSection();
// download section
DistributionManagement distributionManagement = project.getDistributionManagement();
if ( distributionManagement != null )
{
if ( StringUtils.isNotEmpty( distributionManagement.getDownloadUrl() ) )
{
startSection( getI18nString( "download" ) );
link( distributionManagement.getDownloadUrl(), distributionManagement.getDownloadUrl() );
endSection();
}
}
endSection();
}
private String getMinimumJavaVersion()
{
Xpp3Dom pluginConfig =
project.getGoalConfiguration( "org.apache.maven.plugins", "maven-compiler-plugin", null, null );
String source = null;
String target = null;
String compilerVersion = null;
if ( pluginConfig != null )
{
source = getChildValue( pluginConfig, "source" );
target = getChildValue( pluginConfig, "target" );
String fork = getChildValue( pluginConfig, "fork" );
if ( "true".equalsIgnoreCase( fork ) )
{
compilerVersion = getChildValue( pluginConfig, "compilerVersion" );
}
}
String minimumJavaVersion = compilerVersion;
if ( target != null )
{
minimumJavaVersion = target;
}
else if ( source != null )
{
minimumJavaVersion = source;
}
else if ( compilerVersion != null )
{
minimumJavaVersion = compilerVersion;
}
else
{
// no source, target, compilerVersion: toolchain? default target attribute of current
// maven-compiler-plugin's version? analyze packaged jar (like dependencies)?
}
return minimumJavaVersion;
}
private String getChildValue( Xpp3Dom parent, String childName )
{
if ( parent == null )
{
return null;
}
Xpp3Dom child = parent.getChild( childName );
if ( child == null )
{
return null;
}
String value = child.getValue();
if ( value == null || value.trim().length() == 0 )
{
return null;
}
return value.trim();
}
private void tableRowWithLink( String[] content )
{
sink.tableRow();
for ( int ctr = 0; ctr < content.length; ctr++ )
{
String cell = content[ctr];
sink.tableCell();
if ( StringUtils.isEmpty( cell ) )
{
sink.text( "-" );
}
else if ( ctr == content.length - 1 && cell.length() > 0 )
{
sink.link( cell );
sink.text( cell );
sink.link_();
}
else
{
sink.text( cell );
}
sink.tableCell_();
}
sink.tableRow_();
}
/**
* @param project not null
* @return return true
if the Maven project sounds like a Java Project, i.e. has a java type
* packaging (like jar, war...) or java files in the source directory, false
otherwise.
* @since 2.3
*/
private boolean isJavaProject( MavenProject project )
{
String packaging = project.getPackaging().trim().toLowerCase( Locale.ENGLISH );
if ( packaging.equals( "pom" ) )
{
return false;
}
// some commons java packaging
if ( packaging.equals( "jar" ) || packaging.equals( "ear" ) || packaging.equals( "war" )
|| packaging.equals( "rar" ) || packaging.equals( "sar" ) || packaging.equals( "har" )
|| packaging.equals( "par" ) || packaging.equals( "ejb" ) )
{
return true;
}
// java files in the source directory?
final File sourceDir = new File( project.getBuild().getSourceDirectory() );
if ( sourceDir.exists() )
{
try
{
if ( FileUtils.getFileNames( sourceDir, "**/*.java", null, false ).size() > 0 )
{
return true;
}
}
catch ( IOException e )
{
//ignored
}
}
// maven-compiler-plugin ?
Xpp3Dom pluginConfig =
project.getGoalConfiguration( "org.apache.maven.plugins", "maven-compiler-plugin", null, null );
if ( pluginConfig != null )
{
return true;
}
return false;
}
}
}
ScmReport.java 0000664 0000000 0000000 00000072076 11634435442 0034205 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo package org.apache.maven.report.projectinfo;
/*
* 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 org.apache.commons.lang.SystemUtils;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.model.Model;
import org.apache.maven.model.Scm;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.scm.manager.NoSuchScmProviderException;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository;
import org.apache.maven.scm.provider.hg.repository.HgScmProviderRepository;
import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
import org.apache.maven.scm.repository.ScmRepository;
import org.apache.maven.scm.repository.ScmRepositoryException;
import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* Generates the Project Source Code Management (SCM) report.
*
* @author Vincent Siveton
* @version $Id: ScmReport.java 1038048 2010-11-23 10:52:14Z vsiveton $
* @since 2.0
* @goal scm
*/
public class ScmReport
extends AbstractProjectInfoReport
{
// ----------------------------------------------------------------------
// Mojo parameters
// ----------------------------------------------------------------------
/**
* Maven SCM Manager.
*
* @component
*/
protected ScmManager scmManager;
/**
* The directory name to checkout right after the SCM URL.
*
* @parameter default-value="${project.artifactId}"
* @required
*/
private String checkoutDirectoryName;
/**
* The SCM anonymous connection url respecting the SCM URL Format.
*
* @parameter default-value="${project.scm.connection}"
* @since 2.1
* @see SCM URL Format< /a>
*/
private String anonymousConnection;
/**
* The SCM developer connection url respecting the SCM URL Format.
*
* @parameter default-value="${project.scm.developerConnection}"
* @since 2.1
* @see SCM URL Format< /a>
*/
private String developerConnection;
/**
* The SCM web access url.
*
* @parameter default-value="${project.scm.url}"
* @since 2.1
*/
private String webAccessUrl;
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@Override
public void executeReport( Locale locale )
{
ScmRenderer r = new ScmRenderer( getLog(), scmManager, getSink(), getProject().getModel(), getI18N( locale ), locale,
checkoutDirectoryName, webAccessUrl, anonymousConnection,
developerConnection );
r.render();
}
/** {@inheritDoc} */
public String getOutputName()
{
return "source-repository";
}
@Override
protected String getI18Nsection()
{
return "scm";
}
// ----------------------------------------------------------------------
// Private
// ----------------------------------------------------------------------
/**
* Internal renderer class
*/
private static class ScmRenderer
extends AbstractProjectInfoRenderer
{
private Log log;
private Model model;
private ScmManager scmManager;
/**
* To support more SCM
*/
private String anonymousConnection;
private String devConnection;
private String checkoutDirectoryName;
private String webAccessUrl;
ScmRenderer( Log log, ScmManager scmManager, Sink sink, Model model, I18N i18n, Locale locale,
String checkoutDirName, String webAccessUrl, String anonymousConnection, String devConnection )
{
super( sink, i18n, locale );
this.log = log;
this.scmManager = scmManager;
this.model = model;
this.checkoutDirectoryName = checkoutDirName;
this.webAccessUrl = webAccessUrl;
this.anonymousConnection = anonymousConnection;
this.devConnection = devConnection;
}
@Override
protected String getI18Nsection()
{
return "scm";
}
@Override
public void renderBody()
{
Scm scm = model.getScm();
if ( scm == null )
{
startSection( getTitle() );
paragraph( getI18nString( "noscm" ) );
endSection();
return;
}
if ( StringUtils.isEmpty( anonymousConnection ) && StringUtils.isEmpty( devConnection )
&& StringUtils.isEmpty( scm.getUrl() ) )
{
startSection( getTitle() );
paragraph( getI18nString( "noscm" ) );
endSection();
return;
}
ScmRepository anonymousRepository = getScmRepository( anonymousConnection );
ScmRepository devRepository = getScmRepository( devConnection );
// Overview section
renderOverViewSection( anonymousRepository );
// Web access section
renderWebAccesSection( webAccessUrl );
// Anonymous access section if needed
renderAnonymousAccessSection( anonymousRepository );
// Developer access section
renderDeveloperAccessSection( devRepository );
// Access from behind a firewall section if needed
renderAccessBehindFirewallSection( devRepository );
// Access through a proxy section if needed
renderAccessThroughProxySection( anonymousRepository, devRepository );
}
/**
* Render the overview section
*
* @param anonymousRepository the anonymous repository
*/
private void renderOverViewSection( ScmRepository anonymousRepository )
{
startSection( getI18nString( "overview.title" ) );
if ( isScmSystem( anonymousRepository, "clearcase" ) )
{
sink.paragraph();
linkPatternedText( getI18nString( "clearcase.intro" ) );
sink.paragraph_();
}
else if ( isScmSystem( anonymousRepository, "cvs" ) )
{
sink.paragraph();
linkPatternedText( getI18nString( "cvs.intro" ) );
sink.paragraph_();
}
else if ( isScmSystem( anonymousRepository, "hg" ) )
{
sink.paragraph();
linkPatternedText( getI18nString( "hg.intro" ) );
sink.paragraph_();
}
else if ( isScmSystem( anonymousRepository, "perforce" ) )
{
sink.paragraph();
linkPatternedText( getI18nString( "perforce.intro" ) );
sink.paragraph_();
}
else if ( isScmSystem( anonymousRepository, "starteam" ) )
{
sink.paragraph();
linkPatternedText( getI18nString( "starteam.intro" ) );
sink.paragraph_();
}
else if ( isScmSystem( anonymousRepository, "svn" ) )
{
sink.paragraph();
linkPatternedText( getI18nString( "svn.intro" ) );
sink.paragraph_();
}
else
{
paragraph( getI18nString( "general.intro" ) );
}
endSection();
}
/**
* Render the web access section
*
* @param scmUrl The URL to the project's browsable repository.
*/
private void renderWebAccesSection( String scmUrl )
{
startSection( getI18nString( "webaccess.title" ) );
if ( StringUtils.isEmpty( scmUrl ) )
{
paragraph( getI18nString( "webaccess.nourl" ) );
}
else
{
paragraph( getI18nString( "webaccess.url" ) );
verbatimLink( scmUrl, scmUrl );
}
endSection();
}
/**
* Render the anonymous access section depending the repository.
* Note: ClearCase, Starteam et Perforce seems to have no anonymous access.
*
* @param anonymousRepository the anonymous repository
*/
private void renderAnonymousAccessSection( ScmRepository anonymousRepository )
{
if ( isScmSystem( anonymousRepository, "clearcase" ) || isScmSystem( anonymousRepository, "perforce" )
|| isScmSystem( anonymousRepository, "starteam" ) || StringUtils.isEmpty( anonymousConnection ) )
{
return;
}
startSection( getI18nString( "anonymousaccess.title" ) );
if ( anonymousRepository != null && isScmSystem( anonymousRepository, "cvs" ) )
{
CvsScmProviderRepository cvsRepo = (CvsScmProviderRepository) anonymousRepository
.getProviderRepository();
anonymousAccessCVS( cvsRepo );
}
if ( anonymousRepository != null && isScmSystem( anonymousRepository, "hg" ) )
{
HgScmProviderRepository hgRepo = (HgScmProviderRepository) anonymousRepository
.getProviderRepository();
anonymousAccessMercurial( hgRepo );
}
else if ( anonymousRepository != null && isScmSystem( anonymousRepository, "svn" ) )
{
SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) anonymousRepository
.getProviderRepository();
anonymousAccessSVN( svnRepo );
}
else
{
paragraph( getI18nString( "anonymousaccess.general.intro" ) );
verbatimText( anonymousConnection.substring( 4 ) );
}
endSection();
}
/**
* Render the developer access section
*
* @param devRepository the dev repository
*/
private void renderDeveloperAccessSection( ScmRepository devRepository )
{
if ( StringUtils.isEmpty( devConnection ) )
{
return;
}
startSection( getI18nString( "devaccess.title" ) );
if ( devRepository != null && isScmSystem( devRepository, "clearcase" ) )
{
developerAccessClearCase();
}
else if ( devRepository != null && isScmSystem( devRepository, "cvs" ) )
{
CvsScmProviderRepository cvsRepo = (CvsScmProviderRepository) devRepository.getProviderRepository();
developerAccessCVS( cvsRepo );
}
else if ( devRepository != null && isScmSystem( devRepository, "hg" ) )
{
HgScmProviderRepository hgRepo = (HgScmProviderRepository) devRepository.getProviderRepository();
developerAccessMercurial( hgRepo );
}
else if ( devRepository != null && isScmSystem( devRepository, "perforce" ) )
{
PerforceScmProviderRepository perforceRepo = (PerforceScmProviderRepository) devRepository
.getProviderRepository();
developerAccessPerforce( perforceRepo );
}
else if ( devRepository != null && isScmSystem( devRepository, "starteam" ) )
{
StarteamScmProviderRepository starteamRepo = (StarteamScmProviderRepository) devRepository
.getProviderRepository();
developerAccessStarteam( starteamRepo );
}
else if ( devRepository != null && isScmSystem( devRepository, "svn" ) )
{
SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) devRepository.getProviderRepository();
developerAccessSVN( svnRepo );
}
else
{
paragraph( getI18nString( "devaccess.general.intro" ) );
verbatimText( devConnection.substring( 4 ) );
}
endSection();
}
/**
* Render the access from behind a firewall section
*
* @param devRepository the dev repository
*/
private void renderAccessBehindFirewallSection( ScmRepository devRepository )
{
startSection( getI18nString( "accessbehindfirewall.title" ) );
if ( devRepository != null && isScmSystem( devRepository, "svn" ) )
{
SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) devRepository.getProviderRepository();
paragraph( getI18nString( "accessbehindfirewall.svn.intro" ) );
StringBuffer sb = new StringBuffer();
sb.append( "$ svn checkout " ).append( svnRepo.getUrl() );
sb.append( " " ).append( checkoutDirectoryName );
verbatimText( sb.toString() );
}
else if ( devRepository != null && isScmSystem( devRepository, "cvs" ) )
{
linkPatternedText( getI18nString( "accessbehindfirewall.cvs.intro" ) );
}
else
{
paragraph( getI18nString( "accessbehindfirewall.general.intro" ) );
}
endSection();
}
/**
* Render the access from behind a firewall section
*
* @param anonymousRepository the anonymous repository
* @param devRepository the dev repository
*/
private void renderAccessThroughProxySection( ScmRepository anonymousRepository, ScmRepository devRepository )
{
if ( isScmSystem( anonymousRepository, "svn" ) || isScmSystem( devRepository, "svn" ) )
{
startSection( getI18nString( "accessthroughtproxy.title" ) );
paragraph( getI18nString( "accessthroughtproxy.svn.intro1" ) );
paragraph( getI18nString( "accessthroughtproxy.svn.intro2" ) );
paragraph( getI18nString( "accessthroughtproxy.svn.intro3" ) );
StringBuffer sb = new StringBuffer();
sb.append( "[global]" );
sb.append( SystemUtils.LINE_SEPARATOR );
sb.append( "http-proxy-host = your.proxy.name" ).append( SystemUtils.LINE_SEPARATOR );
sb.append( "http-proxy-port = 3128" ).append( SystemUtils.LINE_SEPARATOR );
verbatimText( sb.toString() );
endSection();
}
}
// Clearcase
/**
* Create the documentation to provide an developer access with a Clearcase
SCM.
* For example, generate the following command line:
* cleartool checkout module
*/
private void developerAccessClearCase()
{
paragraph( getI18nString( "devaccess.clearcase.intro" ) );
StringBuffer command = new StringBuffer();
command.append( "$ cleartool checkout " );
verbatimText( command.toString() );
}
// CVS
/**
* Create the documentation to provide an anonymous access with a CVS
SCM.
* For example, generate the following command line:
* cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
* cvs -z3 -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic co maven-plugins/dist
*
* @param cvsRepo
* @see https://www.cvshome.org/docs/manual/cvs-1.12.12/cvs_16.html#SEC115
*/
private void anonymousAccessCVS( CvsScmProviderRepository cvsRepo )
{
paragraph( getI18nString( "anonymousaccess.cvs.intro" ) );
StringBuffer command = new StringBuffer();
command.append( "$ cvs -d " ).append( cvsRepo.getCvsRoot() ).append( " login" );
command.append( SystemUtils.LINE_SEPARATOR );
command.append( "$ cvs -z3 -d " ).append( cvsRepo.getCvsRoot() );
command.append( " co " ).append( cvsRepo.getModule() );
verbatimText( command.toString() );
}
// Mercurial
/**
* Create the documentation to provide an anonymous access with a Mercurial
SCM.
* For example, generate the following command line:
* hg clone uri
*
* @param hgRepo
*/
private void anonymousAccessMercurial( HgScmProviderRepository hgRepo )
{
sink.paragraph();
linkPatternedText( getI18nString( "anonymousaccess.hg.intro" ) );
sink.paragraph_();
StringBuffer command = new StringBuffer();
command.append( "$ hg clone " ).append( hgRepo.getURI() );
verbatimText( command.toString() );
}
/**
* Create the documentation to provide an developer access with a CVS
SCM.
* For example, generate the following command line:
* cvs -d :pserver:username@cvs.apache.org:/home/cvs login
* cvs -z3 -d :ext:username@cvs.apache.org:/home/cvs co maven-plugins/dist
*
* @param cvsRepo
* @see https://www.cvshome.org/docs/manual/cvs-1.12.12/cvs_16.html#SEC115
*/
private void developerAccessCVS( CvsScmProviderRepository cvsRepo )
{
paragraph( getI18nString( "devaccess.cvs.intro" ) );
// Safety: remove the username if present
String cvsRoot = StringUtils.replace( cvsRepo.getCvsRoot(), cvsRepo.getUser(), "username" );
StringBuffer command = new StringBuffer();
command.append( "$ cvs -d " ).append( cvsRoot ).append( " login" );
command.append( SystemUtils.LINE_SEPARATOR );
command.append( "$ cvs -z3 -d " ).append( cvsRoot ).append( " co " ).append( cvsRepo.getModule() );
verbatimText( command.toString() );
}
// Mercurial
/**
* Create the documentation to provide an developer access with a Mercurial
SCM.
* For example, generate the following command line:
* hg clone repo
*
* @param hgRepo
*/
private void developerAccessMercurial(HgScmProviderRepository hgRepo)
{
sink.paragraph();
linkPatternedText( getI18nString( "devaccess.hg.intro" ) );
sink.paragraph_();
StringBuffer command = new StringBuffer();
command.append( "$ hg clone " );
command.append(hgRepo.getURI());
verbatimText( command.toString() );
}
// Perforce
/**
* Create the documentation to provide an developer access with a Perforce
SCM.
* For example, generate the following command line:
* p4 -H hostname -p port -u username -P password path
* p4 -H hostname -p port -u username -P password path submit -c changement
*
* @param perforceRepo
* @see http://www.perforce.com/perforce/doc.051/manuals/cmdref/index.html>
*/
private void developerAccessPerforce( PerforceScmProviderRepository perforceRepo )
{
paragraph( getI18nString( "devaccess.perforce.intro" ) );
StringBuffer command = new StringBuffer();
command.append( "$ p4" );
if ( !StringUtils.isEmpty( perforceRepo.getHost() ) )
{
command.append( " -H " ).append( perforceRepo.getHost() );
}
if ( perforceRepo.getPort() > 0 )
{
command.append( " -p " ).append( perforceRepo.getPort() );
}
command.append( " -u username" );
command.append( " -P password" );
command.append( " " );
command.append( perforceRepo.getPath() );
command.append( SystemUtils.LINE_SEPARATOR );
command.append( "$ p4 submit -c \"A comment\"" );
verbatimText( command.toString() );
}
// Starteam
/**
* Create the documentation to provide an developer access with a Starteam
SCM.
* For example, generate the following command line:
* stcmd co -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl -is
* stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl -f NCI -is
*
* @param starteamRepo
*/
private void developerAccessStarteam( StarteamScmProviderRepository starteamRepo )
{
paragraph( getI18nString( "devaccess.starteam.intro" ) );
StringBuffer command = new StringBuffer();
// Safety: remove the username/password if present
String fullUrl = StringUtils.replace( starteamRepo.getFullUrl(), starteamRepo.getUser(), "username" );
fullUrl = StringUtils.replace( fullUrl, starteamRepo.getPassword(), "password" );
command.append( "$ stcmd co -x -nologo -stop -p " );
command.append( fullUrl );
command.append( " -is" );
command.append( SystemUtils.LINE_SEPARATOR );
command.append( "$ stcmd ci -x -nologo -stop -p " );
command.append( fullUrl );
command.append( " -f NCI -is" );
verbatimText( command.toString() );
}
// SVN
/**
* Create the documentation to provide an anonymous access with a SVN
SCM.
* For example, generate the following command line:
* svn checkout http://svn.apache.org/repos/asf/maven/components/trunk maven
*
* @param svnRepo
* @see http://svnbook.red-bean.com/
*/
private void anonymousAccessSVN( SvnScmProviderRepository svnRepo )
{
paragraph( getI18nString( "anonymousaccess.svn.intro" ) );
StringBuffer sb = new StringBuffer();
sb.append( "$ svn checkout " ).append( svnRepo.getUrl() ).append( " " ).append( checkoutDirectoryName );
verbatimText( sb.toString() );
}
/**
* Create the documentation to provide an developer access with a SVN
SCM.
* For example, generate the following command line:
* svn checkout https://svn.apache.org/repos/asf/maven/components/trunk maven
* svn commit --username your-username -m "A message"
*
* @param svnRepo
* @see http://svnbook.red-bean.com/
*/
private void developerAccessSVN( SvnScmProviderRepository svnRepo )
{
if ( svnRepo.getUrl() != null )
{
if ( svnRepo.getUrl().startsWith( "https://" ) )
{
paragraph( getI18nString( "devaccess.svn.intro1.https" ) );
}
else if ( svnRepo.getUrl().startsWith( "svn://" ) )
{
paragraph( getI18nString( "devaccess.svn.intro1.svn" ) );
}
else if ( svnRepo.getUrl().startsWith( "svn+ssh://" ) )
{
paragraph( getI18nString( "devaccess.svn.intro1.svnssh" ) );
}
else
{
paragraph( getI18nString( "devaccess.svn.intro1.other" ) );
}
}
StringBuffer sb = new StringBuffer();
sb.append( "$ svn checkout " ).append( svnRepo.getUrl() ).append( " " ).append( checkoutDirectoryName );
verbatimText( sb.toString() );
paragraph( getI18nString( "devaccess.svn.intro2" ) );
sb = new StringBuffer();
sb.append( "$ svn commit --username your-username -m \"A message\"" );
verbatimText( sb.toString() );
}
/**
* Return a SCM repository
defined by a given url
*
* @param scmUrl an SCM URL
* @return a valid SCM repository or null
*/
@SuppressWarnings( "unchecked" )
public ScmRepository getScmRepository( String scmUrl )
{
if ( StringUtils.isEmpty( scmUrl ) )
{
return null;
}
ScmRepository repo = null;
List messages = new ArrayList();
try
{
messages.addAll( scmManager.validateScmRepository( scmUrl ) );
}
catch ( Exception e )
{
messages.add( e.getMessage() );
}
if ( messages.size() > 0 )
{
StringBuffer sb = new StringBuffer();
boolean isIntroAdded = false;
for ( String msg : messages )
{
// Ignore NoSuchScmProviderException msg
// See impl of AbstractScmManager#validateScmRepository()
if ( msg.startsWith( "No such provider" ) )
{
continue;
}
if ( !isIntroAdded )
{
sb.append( "This SCM url '" + scmUrl + "' is invalid due to the following errors:" );
sb.append( SystemUtils.LINE_SEPARATOR );
isIntroAdded = true;
}
sb.append( " * " );
sb.append( msg );
sb.append( SystemUtils.LINE_SEPARATOR );
}
if ( StringUtils.isNotEmpty( sb.toString() ) )
{
sb.append( "For more information about SCM URL Format, please refer to: "
+ "http://maven.apache.org/scm/scm-url-format.html" );
throw new IllegalArgumentException( sb.toString() );
}
}
try
{
repo = scmManager.makeScmRepository( scmUrl );
}
catch ( NoSuchScmProviderException e )
{
if ( log.isDebugEnabled() )
{
log.debug( e.getMessage(), e );
}
}
catch ( ScmRepositoryException e )
{
if ( log.isDebugEnabled() )
{
log.debug( e.getMessage(), e );
}
}
catch ( Exception e )
{
// Should be already catched
if ( log.isDebugEnabled() )
{
log.debug( e.getMessage(), e );
}
}
return repo;
}
/**
* Convenience method that return true is the defined SCM repository
is a known provider.
*
* Actually, we fully support Clearcase, CVS, Perforce, Starteam, SVN by the maven-scm-providers component.
*
*
* @param scmRepository a SCM repository
* @param scmProvider a SCM provider name
* @return true if the provider of the given SCM repository is equal to the given scm provider.
* @see maven-scm-providers
*/
private static boolean isScmSystem( ScmRepository scmRepository, String scmProvider )
{
if ( StringUtils.isEmpty( scmProvider ) )
{
return false;
}
if ( scmRepository != null && scmProvider.equalsIgnoreCase( scmRepository.getProvider() ) )
{
return true;
}
return false;
}
}
}
TeamListReport.java 0000664 0000000 0000000 00000051007 11634435442 0035174 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo package org.apache.maven.report.projectinfo;
/*
* 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 org.apache.commons.lang.SystemUtils;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.model.Contributor;
import org.apache.maven.model.Developer;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.util.StringUtils;
import org.joda.time.DateTimeZone;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.TimeZone;
/**
* Generates the Project Team report.
*
* @author Vincent Siveton
* @version $Id: TeamListReport.java 1098769 2011-05-02 20:00:24Z hboutemy $
* @since 2.0
* @goal project-team
*/
public class TeamListReport
extends AbstractProjectInfoReport
{
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@Override
public void executeReport( Locale locale )
{
TeamListRenderer r = new TeamListRenderer( getSink(), project.getModel(), getI18N( locale ), locale, getLog() );
r.render();
}
/** {@inheritDoc} */
public String getOutputName()
{
return "team-list";
}
@Override
protected String getI18Nsection()
{
return "team-list";
}
// ----------------------------------------------------------------------
// Private
// ----------------------------------------------------------------------
/**
* Internal renderer class
*/
private static class TeamListRenderer
extends AbstractProjectInfoRenderer
{
private static final String PROPERTIES = "properties";
private static final String TIME_ZONE = "timeZone";
private static final String ROLES = "roles";
private static final String ORGANIZATION_URL = "organizationUrl";
private static final String ORGANIZATION = "organization";
private static final String URL = "url";
private static final String EMAIL = "email";
private static final String NAME = "name";
private static final String ID = "id";
private final Model model;
private final Log log;
private static final String[] EMPTY_STRING_ARRAY = new String[0];
TeamListRenderer( Sink sink, Model model, I18N i18n, Locale locale, Log log )
{
super( sink, i18n, locale );
this.model = model;
this.log = log;
}
@Override
protected String getI18Nsection()
{
return "team-list";
}
@Override
public void renderBody()
{
startSection( getI18nString( "intro.title" ) );
// To handle JS
StringBuffer javascript = new StringBuffer( "function offsetDate(id, offset) {" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( " var now = new Date();" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( " var nowTime = now.getTime();" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( " var localOffset = now.getTimezoneOffset();" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( " var developerTime = nowTime + ( offset * 60 * 60 * 1000 )"
+ "+ ( localOffset * 60 * 1000 );" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( " var developerDate = new Date(developerTime);" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( SystemUtils.LINE_SEPARATOR );
javascript.append( " document.getElementById(id).innerHTML = developerDate;" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( "}" ).append( SystemUtils.LINE_SEPARATOR );
javascript.append( SystemUtils.LINE_SEPARATOR);
javascript.append( "function init(){" ).append( SystemUtils.LINE_SEPARATOR );
// Introduction
paragraph( getI18nString( "intro.description1" ) );
paragraph( getI18nString( "intro.description2" ) );
// Developer section
List developers = model.getDevelopers();
startSection( getI18nString( "developers.title" ) );
if ( isEmpty( developers ) )
{
paragraph( getI18nString( "nodeveloper" ) );
}
else
{
paragraph( getI18nString( "developers.intro" ) );
startTable();
// By default we think that all headers not required: set true for headers that are required
Map headersMap = checkRequiredHeaders( developers );
String[] requiredHeaders = getRequiredDevHeaderArray( headersMap );
tableHeader( requiredHeaders );
// To handle JS
int developersRowId = 0;
for ( Developer developer : developers )
{
renderTeamMember( developer, developersRowId, headersMap, javascript );
developersRowId++;
}
endTable();
}
endSection();
// contributors section
List contributors = model.getContributors();
startSection( getI18nString( "contributors.title" ) );
if ( isEmpty( contributors ) )
{
paragraph( getI18nString( "nocontributor" ) );
}
else
{
paragraph( getI18nString( "contributors.intro" ) );
startTable();
Map headersMap = checkRequiredHeaders( contributors );
String[] requiredHeaders = getRequiredContrHeaderArray( headersMap );
tableHeader( requiredHeaders );
// To handle JS
int contributorsRowId = 0;
for ( Contributor contributor : contributors )
{
renderTeamMember( contributor, contributorsRowId, headersMap, javascript );
contributorsRowId++;
}
endTable();
}
// To handle JS
javascript.append( "}" ).append( SystemUtils.LINE_SEPARATOR ).append( SystemUtils.LINE_SEPARATOR )
.append( "window.onLoad = init();" ).append( SystemUtils.LINE_SEPARATOR );
javaScript( javascript.toString() );
endSection();
endSection();
}
private void renderTeamMember( Contributor member, int rowId, Map headersMap,
StringBuffer javascript )
{
sink.tableRow();
String type = "contributor";
if ( member instanceof Developer )
{
type = "developer";
if ( headersMap.get( ID ) == Boolean.TRUE )
{
String id = ( (Developer) member ).getId();
if ( id == null )
{
tableCell( null );
}
else
{
tableCell( "" + id, true );
}
}
}
if ( headersMap.get( NAME ) == Boolean.TRUE )
{
tableCell( member.getName() );
}
if ( headersMap.get( EMAIL ) == Boolean.TRUE )
{
tableCell( createLinkPatternedText( member.getEmail(), member.getEmail() ) );
}
if ( headersMap.get( URL ) == Boolean.TRUE )
{
tableCellForUrl( member.getUrl() );
}
if ( headersMap.get( ORGANIZATION ) == Boolean.TRUE )
{
tableCell( member.getOrganization() );
}
if ( headersMap.get( ORGANIZATION_URL ) == Boolean.TRUE )
{
tableCellForUrl( member.getOrganizationUrl() );
}
if ( headersMap.get( ROLES ) == Boolean.TRUE )
{
if ( member.getRoles() != null )
{
// Comma separated roles
tableCell( StringUtils.join( member.getRoles().toArray( EMPTY_STRING_ARRAY ), ", " ) );
}
else
{
tableCell( null );
}
}
if ( headersMap.get( TIME_ZONE ) == Boolean.TRUE )
{
tableCell( member.getTimezone() );
if ( StringUtils.isNotEmpty( member.getTimezone() )
&& ( !ProjectInfoReportUtils.isNumber( member.getTimezone().trim() ) ) )
{
String tz = member.getTimezone().trim();
try
{
// check if it is a valid timeZone
DateTimeZone.forID( tz );
sink.tableCell();
sink.rawText( "" );
text( tz );
String offSet = String.valueOf( TimeZone.getTimeZone( tz ).getRawOffset() / 3600000 );
javascript.append( " offsetDate('" ).append( type ).append( "-" ).append( rowId ).append( "', '" );
javascript.append( offSet ).append( "');" ).append( SystemUtils.LINE_SEPARATOR );
sink.rawText( "" );
sink.tableCell_();
}
catch ( IllegalArgumentException e )
{
log.warn( "The time zone '" + tz + "' for the " + type + " '" + member.getName()
+ "' is not a recognised time zone, use a number in the range -12 and +14 instead of." );
sink.tableCell();
sink.rawText( "" );
text( null );
sink.rawText( "" );
sink.tableCell_();
}
}
else
{
// To handle JS
sink.tableCell();
sink.rawText( "" );
if ( StringUtils.isEmpty( member.getTimezone() ) )
{
text( null );
}
else
{
// check if number is between -12 and +14
float tz = ProjectInfoReportUtils.toFloat( member.getTimezone().trim(), Integer.MIN_VALUE );
if ( tz == Integer.MIN_VALUE || !( tz >= -12 && tz <= 14 ) )
{
text( null );
log.warn( "The time zone '" + member.getTimezone().trim() + "' for the " + type + " '"
+ member.getName()
+ "' is not a recognised time zone, use a number in the range -12 to +14 instead of." );
}
else
{
text( member.getTimezone().trim() );
javascript.append( " offsetDate('" ).append( type ).append( "-" ).append( rowId ).append( "', '" );
javascript.append( member.getTimezone() ).append( "');" ).append( SystemUtils.LINE_SEPARATOR );
}
}
sink.rawText( "" );
sink.tableCell_();
}
}
if ( headersMap.get( PROPERTIES ) == Boolean.TRUE )
{
Properties props = member.getProperties();
if ( props != null )
{
tableCell( propertiesToString( props ) );
}
else
{
tableCell( null );
}
}
sink.tableRow_();
}
/**
* @param requiredHeaders
* @return
*/
private String[] getRequiredContrHeaderArray( Map requiredHeaders )
{
List requiredArray = new ArrayList();
String name = getI18nString( "contributors.name" );
String email = getI18nString( "contributors.email" );
String url = getI18nString( "contributors.url" );
String organization = getI18nString( "contributors.organization" );
String organizationUrl = getI18nString( "contributors.organizationurl" );
String roles = getI18nString( "contributors.roles" );
String timeZone = getI18nString( "contributors.timezone" );
String actualTime = getI18nString( "contributors.actualtime" );
String properties = getI18nString( "contributors.properties" );
setRequiredArray( requiredHeaders, requiredArray, name, email, url, organization, organizationUrl, roles,
timeZone, actualTime, properties );
return requiredArray.toArray( new String[requiredArray.size()] );
}
/**
* @param requiredHeaders
* @return
*/
private String[] getRequiredDevHeaderArray( Map requiredHeaders )
{
List requiredArray = new ArrayList();
String id = getI18nString( "developers.id" );
String name = getI18nString( "developers.name" );
String email = getI18nString( "developers.email" );
String url = getI18nString( "developers.url" );
String organization = getI18nString( "developers.organization" );
String organizationUrl = getI18nString( "developers.organizationurl" );
String roles = getI18nString( "developers.roles" );
String timeZone = getI18nString( "developers.timezone" );
String actualTime = getI18nString( "developers.actualtime" );
String properties = getI18nString( "developers.properties" );
if ( requiredHeaders.get( ID ) == Boolean.TRUE )
{
requiredArray.add( id );
}
setRequiredArray( requiredHeaders, requiredArray, name, email, url, organization, organizationUrl, roles,
timeZone, actualTime, properties );
return requiredArray.toArray( new String[requiredArray.size()] );
}
/**
* @param requiredHeaders
* @param requiredArray
* @param name
* @param email
* @param url
* @param organization
* @param organizationUrl
* @param roles
* @param timeZone
* @param actualTime
* @param properties
*/
private void setRequiredArray( Map requiredHeaders, List requiredArray, String name,
String email, String url, String organization, String organizationUrl,
String roles, String timeZone, String actualTime, String properties )
{
if ( requiredHeaders.get( NAME ) == Boolean.TRUE )
{
requiredArray.add( name );
}
if ( requiredHeaders.get( EMAIL ) == Boolean.TRUE )
{
requiredArray.add( email );
}
if ( requiredHeaders.get( URL ) == Boolean.TRUE )
{
requiredArray.add( url );
}
if ( requiredHeaders.get( ORGANIZATION ) == Boolean.TRUE )
{
requiredArray.add( organization );
}
if ( requiredHeaders.get( ORGANIZATION_URL ) == Boolean.TRUE )
{
requiredArray.add( organizationUrl );
}
if ( requiredHeaders.get( ROLES ) == Boolean.TRUE )
{
requiredArray.add( roles );
}
if ( requiredHeaders.get( TIME_ZONE ) == Boolean.TRUE )
{
requiredArray.add( timeZone );
requiredArray.add( actualTime );
}
if ( requiredHeaders.get( PROPERTIES ) == Boolean.TRUE )
{
requiredArray.add( properties );
}
}
/**
* @param units contributors and developers to check
* @return required headers
*/
private Map checkRequiredHeaders( List extends Contributor> units )
{
Map requiredHeaders = new HashMap();
requiredHeaders.put( ID, Boolean.FALSE );
requiredHeaders.put( NAME, Boolean.FALSE );
requiredHeaders.put( EMAIL, Boolean.FALSE );
requiredHeaders.put( URL, Boolean.FALSE );
requiredHeaders.put( ORGANIZATION, Boolean.FALSE );
requiredHeaders.put( ORGANIZATION_URL, Boolean.FALSE );
requiredHeaders.put( ROLES, Boolean.FALSE );
requiredHeaders.put( TIME_ZONE, Boolean.FALSE );
requiredHeaders.put( PROPERTIES, Boolean.FALSE );
for ( Contributor unit : units )
{
if ( unit instanceof Developer )
{
Developer developer = (Developer) unit;
if ( StringUtils.isNotEmpty( developer.getId() ) )
{
requiredHeaders.put( ID, Boolean.TRUE );
}
}
if ( StringUtils.isNotEmpty( unit.getName() ) )
{
requiredHeaders.put( NAME, Boolean.TRUE );
}
if ( StringUtils.isNotEmpty( unit.getEmail() ) )
{
requiredHeaders.put( EMAIL, Boolean.TRUE );
}
if ( StringUtils.isNotEmpty( unit.getUrl() ) )
{
requiredHeaders.put( URL, Boolean.TRUE );
}
if ( StringUtils.isNotEmpty( unit.getOrganization() ) )
{
requiredHeaders.put( ORGANIZATION, Boolean.TRUE );
}
if ( StringUtils.isNotEmpty( unit.getOrganizationUrl() ) )
{
requiredHeaders.put( ORGANIZATION_URL, Boolean.TRUE );
}
if ( !isEmpty( unit.getRoles() ) )
{
requiredHeaders.put( ROLES, Boolean.TRUE );
}
if ( StringUtils.isNotEmpty( unit.getTimezone() ) )
{
requiredHeaders.put( TIME_ZONE, Boolean.TRUE );
}
Properties properties = unit.getProperties();
if ( null != properties && !properties.isEmpty() )
{
requiredHeaders.put( PROPERTIES, Boolean.TRUE );
}
}
return requiredHeaders;
}
/**
* Create a table cell with a link to the given url. The url is not validated.
*
* @param url
*/
private void tableCellForUrl( String url )
{
sink.tableCell();
if ( StringUtils.isEmpty( url ) )
{
text( url );
}
else
{
link( url, url );
}
sink.tableCell_();
}
private boolean isEmpty( List> list )
{
return ( list == null ) || list.isEmpty();
}
}
}
0000775 0000000 0000000 00000000000 11634435442 0034036 5 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo/dependencies Dependencies.java 0000664 0000000 0000000 00000021630 11634435442 0037271 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo/dependencies package org.apache.maven.report.projectinfo.dependencies;
/*
* 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.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.JarEntry;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.jar.JarAnalyzer;
import org.apache.maven.shared.jar.JarData;
import org.apache.maven.shared.jar.classes.JarClasses;
import org.apache.maven.shared.jar.classes.JarClassesAnalysis;
/**
* @version $Id: Dependencies.java 1103555 2011-05-15 22:08:21Z hboutemy $
* @since 2.1
*/
public class Dependencies
{
private final MavenProject project;
private final DependencyNode dependencyTreeNode;
private final JarClassesAnalysis classesAnalyzer;
/**
* @since 2.1
*/
private List projectDependencies;
/**
* @since 2.1
*/
private List projectTransitiveDependencies;
/**
* @since 2.1
*/
private List allDependencies;
/**
* @since 2.1
*/
private Map> dependenciesByScope;
/**
* @since 2.1
*/
private Map> transitiveDependenciesByScope;
/**
* @since 2.1
*/
private Map dependencyDetails;
/**
* Default constructor
*
* @param project the MavenProject.
* @param dependencyTreeNode the DependencyNode.
* @param classesAnalyzer the JarClassesAnalysis.
*/
public Dependencies( MavenProject project, DependencyNode dependencyTreeNode, JarClassesAnalysis classesAnalyzer )
{
this.project = project;
this.dependencyTreeNode = dependencyTreeNode;
this.classesAnalyzer = classesAnalyzer;
}
/**
* Getter for the project
*
* @return the project
*/
public MavenProject getProject()
{
return project;
}
/**
* @return true
if getProjectDependencies() is not empty, false
otherwise.
*/
public boolean hasDependencies()
{
return ( getProjectDependencies() != null ) && ( !getProjectDependencies().isEmpty() );
}
/**
* @return a list of Artifact
from the project.
*/
public List getProjectDependencies()
{
if ( projectDependencies != null )
{
return projectDependencies;
}
projectDependencies = new ArrayList();
@SuppressWarnings( "unchecked" )
List deps = dependencyTreeNode.getChildren();
for ( DependencyNode dep : deps )
{
projectDependencies.add( dep.getArtifact() );
}
return projectDependencies;
}
/**
* @return a list of transitive Artifact
from the project.
*/
public List getTransitiveDependencies()
{
if ( projectTransitiveDependencies != null )
{
return projectTransitiveDependencies;
}
projectTransitiveDependencies = new ArrayList( getAllDependencies() );
projectTransitiveDependencies.removeAll( getProjectDependencies() );
return projectTransitiveDependencies;
}
/**
* @return a list of included Artifact
returned by the dependency tree.
*/
public List getAllDependencies()
{
if ( allDependencies != null )
{
return allDependencies;
}
allDependencies = new ArrayList();
addAllChildrenDependencies( dependencyTreeNode );
return allDependencies;
}
/**
* @param isTransitively true
to return transitive dependencies, false
otherwise.
* @return a map with supported scopes as key and a list of Artifact
as values.
* @see Artifact#SCOPE_COMPILE
* @see Artifact#SCOPE_PROVIDED
* @see Artifact#SCOPE_RUNTIME
* @see Artifact#SCOPE_SYSTEM
* @see Artifact#SCOPE_TEST
*/
public Map> getDependenciesByScope( boolean isTransitively )
{
if ( isTransitively )
{
if ( transitiveDependenciesByScope != null )
{
return transitiveDependenciesByScope;
}
transitiveDependenciesByScope = new HashMap>();
for ( Artifact artifact : getTransitiveDependencies() )
{
List multiValue = transitiveDependenciesByScope.get( artifact.getScope() );
if ( multiValue == null )
{
multiValue = new ArrayList();
}
if ( !multiValue.contains( artifact ) )
{
multiValue.add( artifact );
}
transitiveDependenciesByScope.put( artifact.getScope(), multiValue );
}
return transitiveDependenciesByScope;
}
if ( dependenciesByScope != null )
{
return dependenciesByScope;
}
dependenciesByScope = new HashMap>();
for ( Artifact artifact : getProjectDependencies() )
{
List multiValue = dependenciesByScope.get( artifact.getScope() );
if ( multiValue == null )
{
multiValue = new ArrayList();
}
if ( !multiValue.contains( artifact ) )
{
multiValue.add( artifact );
}
dependenciesByScope.put( artifact.getScope(), multiValue );
}
return dependenciesByScope;
}
/**
* @param artifact the artifact.
* @return the jardata object from the artifact
* @throws IOException if any
*/
public JarData getJarDependencyDetails( Artifact artifact )
throws IOException
{
if ( dependencyDetails == null )
{
dependencyDetails = new HashMap();
}
JarData jarData = dependencyDetails.get( artifact.getId() );
if ( jarData != null )
{
return jarData;
}
if ( artifact.getFile().isDirectory() )
{
jarData = new JarData( artifact.getFile(), null, new ArrayList() );
jarData.setJarClasses( new JarClasses() );
}
else
{
JarAnalyzer jarAnalyzer = new JarAnalyzer( artifact.getFile() );
try
{
classesAnalyzer.analyze( jarAnalyzer );
}
finally
{
jarAnalyzer.closeQuietly();
}
jarData = jarAnalyzer.getJarData();
}
dependencyDetails.put( artifact.getId(), jarData );
return jarData;
}
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
/**
* Recursive method to get all dependencies from a given dependencyNode
*
* @param dependencyNode not null
*/
private void addAllChildrenDependencies( DependencyNode dependencyNode )
{
@SuppressWarnings( "unchecked" )
List deps = dependencyNode.getChildren();
for ( DependencyNode subdependencyNode : deps )
{
if ( subdependencyNode.getState() != DependencyNode.INCLUDED )
{
continue;
}
Artifact artifact = subdependencyNode.getArtifact();
if ( artifact.getGroupId().equals( project.getGroupId() )
&& artifact.getArtifactId().equals( project.getArtifactId() )
&& artifact.getVersion().equals( project.getVersion() ) )
{
continue;
}
if ( !allDependencies.contains( artifact ) )
{
allDependencies.add( artifact );
}
addAllChildrenDependencies( subdependencyNode );
}
}
}
DependenciesReportConfiguration.java 0000664 0000000 0000000 00000003556 11634435442 0043224 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo/dependencies package org.apache.maven.report.projectinfo.dependencies;
/*
* 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.
*/
/**
* Wrap DependenciesReport Mojo parameters.
*
* @version $Id: DependenciesReportConfiguration.java 890109 2009-12-13 19:57:28Z ltheussl $
* @since 2.1
*/
public class DependenciesReportConfiguration
{
private boolean dependencyDetailsEnabled;
private boolean dependencyLocationsEnabled;
/**
* @param detailsEnabled whether details is enabled.
* @param locationEnabled whether location is enabled.
*/
public DependenciesReportConfiguration( boolean detailsEnabled, boolean locationEnabled )
{
this.dependencyDetailsEnabled = detailsEnabled;
this.dependencyLocationsEnabled = locationEnabled;
}
/**
* @return value of Mojo dependencyDetailsEnabled parameter.
*/
public boolean getDependencyDetailsEnabled()
{
return dependencyDetailsEnabled;
}
/**
* @return value of Mojo dependencyLocationsEnabled parameter.
*/
public boolean getDependencyLocationsEnabled()
{
return dependencyLocationsEnabled;
}
}
ManagementDependencies.java 0000664 0000000 0000000 00000005526 11634435442 0041274 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo/dependencies package org.apache.maven.report.projectinfo.dependencies;
/*
* 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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
/**
* @author Nick Stolwijk
* @version $Id: ManagementDependencies.java 980600 2010-07-29 22:41:33Z hboutemy $
* @since 2.1
*/
public class ManagementDependencies
{
private final List managementDependencies;
/**
* @param projectDependencies the list of dependencies.
*/
public ManagementDependencies( List projectDependencies )
{
this.managementDependencies = projectDependencies;
}
/**
* @return true
if managementDependencies is not null and not empty.
*/
public boolean hasDependencies()
{
return ( managementDependencies != null ) && ( !this.managementDependencies.isEmpty() );
}
/**
* @return managementDependencies
*/
public List getManagementDependencies()
{
return new ArrayList( managementDependencies );
}
/**
* @return the managementDependencies by scope
* @see Artifact#SCOPE_COMPILE
* @see Artifact#SCOPE_PROVIDED
* @see Artifact#SCOPE_RUNTIME
* @see Artifact#SCOPE_SYSTEM
* @see Artifact#SCOPE_TEST
*/
public Map> getManagementDependenciesByScope()
{
Map> dependenciesByScope = new HashMap>();
for ( Dependency dependency : managementDependencies )
{
String scope = dependency.getScope() != null ? dependency.getScope() : Artifact.SCOPE_COMPILE;
List multiValue = dependenciesByScope.get( scope );
if ( multiValue == null )
{
multiValue = new ArrayList();
}
multiValue.add( dependency );
dependenciesByScope.put( scope, multiValue );
}
return dependenciesByScope;
}
}
RepositoryUtils.java 0000664 0000000 0000000 00000035067 11634435442 0040114 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo/dependencies package org.apache.maven.report.projectinfo.dependencies;
/*
* 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.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonConfigurationException;
import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.metadata.Metadata;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.apache.maven.wagon.ConnectionException;
import org.apache.maven.wagon.TransferFailedException;
import org.apache.maven.wagon.UnsupportedProtocolException;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.authorization.AuthorizationException;
import org.apache.maven.wagon.observers.Debug;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.util.StringUtils;
/**
* Utilities methods to play with repository
*
* @version $Id: RepositoryUtils.java 1100809 2011-05-08 20:40:20Z hboutemy $
* @since 2.1
*/
public class RepositoryUtils
{
private static final List UNKNOWN_HOSTS = new ArrayList();
private final Log log;
private final WagonManager wagonManager;
private final Settings settings;
private final MavenProjectBuilder mavenProjectBuilder;
private final ArtifactFactory factory;
private final List remoteRepositories;
private final List pluginRepositories;
private final ArtifactResolver resolver;
private final ArtifactRepository localRepository;
/**
* @param log
* @param wagonManager
* @param settings
* @param mavenProjectBuilder
* @param factory
* @param resolver
* @param remoteRepositories
* @param pluginRepositories
* @param localRepository
* @param repositoryMetadataManager
*/
public RepositoryUtils( Log log, WagonManager wagonManager, Settings settings,
MavenProjectBuilder mavenProjectBuilder, ArtifactFactory factory,
ArtifactResolver resolver, List remoteRepositories,
List pluginRepositories, ArtifactRepository localRepository,
RepositoryMetadataManager repositoryMetadataManager )
{
this.log = log;
this.wagonManager = wagonManager;
this.settings = settings;
this.mavenProjectBuilder = mavenProjectBuilder;
this.factory = factory;
this.resolver = resolver;
this.remoteRepositories = remoteRepositories;
this.pluginRepositories = pluginRepositories;
this.localRepository = localRepository;
}
/**
* @return localrepo
*/
public ArtifactRepository getLocalRepository()
{
return localRepository;
}
/**
* @return remote artifact repo
*/
public List getRemoteArtifactRepositories()
{
return remoteRepositories;
}
/**
* @return plugin artifact repo
*/
public List getPluginArtifactRepositories()
{
return pluginRepositories;
}
/**
* @param artifact not null
* @throws ArtifactResolutionException if any
* @throws ArtifactNotFoundException if any
* @see ArtifactResolver#resolve(Artifact, List, ArtifactRepository)
*/
public void resolve( Artifact artifact )
throws ArtifactResolutionException, ArtifactNotFoundException
{
List repos =
new ArrayList( pluginRepositories.size() + remoteRepositories.size() );
repos.addAll( pluginRepositories );
repos.addAll( remoteRepositories );
resolver.resolve( artifact, repos, localRepository );
}
/**
* @param repo not null
* @param artifact not null
* @return true
if the artifact exists in the given repo, false
otherwise or if
* the repo is blacklisted.
*/
public boolean dependencyExistsInRepo( ArtifactRepository repo, Artifact artifact )
{
if ( repo.isBlacklisted() )
{
if ( log.isDebugEnabled() )
{
log.debug( "The repo '" + repo.getId() + "' is black listed - Ignored it" );
}
return false;
}
if ( UNKNOWN_HOSTS.contains( repo.getUrl() ) )
{
if ( log.isDebugEnabled() )
{
log.debug( "The repo url '" + repo.getUrl() + "' is unknowned - Ignored it" );
}
return false;
}
repo = wagonManager.getMirrorRepository( repo );
String id = repo.getId();
Repository repository = new Repository( id, repo.getUrl() );
Wagon wagon;
try
{
wagon = wagonManager.getWagon( repository );
}
catch ( UnsupportedProtocolException e )
{
logError( "Unsupported protocol: '" + repo.getProtocol() + "'", e );
return false;
}
catch ( WagonConfigurationException e )
{
logError( "Unsupported protocol: '" + repo.getProtocol() + "'", e );
return false;
}
wagon.setTimeout( 1000 );
if ( log.isDebugEnabled() )
{
Debug debug = new Debug();
wagon.addSessionListener( debug );
wagon.addTransferListener( debug );
}
try
{
// FIXME when upgrading to maven 3.x : this must be changed.
AuthenticationInfo auth = wagonManager.getAuthenticationInfo( repo.getId() );
ProxyInfo proxyInfo = getProxyInfo();
if ( proxyInfo != null )
{
wagon.connect( repository, auth, proxyInfo );
}
else
{
wagon.connect( repository, auth );
}
return wagon.resourceExists( StringUtils.replace( getDependencyUrlFromRepository( artifact, repo ),
repo.getUrl(), "" ) );
}
catch ( ConnectionException e )
{
logError( "Unable to connect to: " + repo.getUrl(), e );
return false;
}
catch ( AuthenticationException e )
{
logError( "Unable to connect to: " + repo.getUrl(), e );
return false;
}
catch ( TransferFailedException e )
{
if ( e.getCause() instanceof UnknownHostException )
{
log.error( "Unknown host " + e.getCause().getMessage() + " - ignored it" );
UNKNOWN_HOSTS.add( repo.getUrl() );
}
else
{
logError( "Unable to determine if resource " + artifact + " exists in " + repo.getUrl(), e );
}
return false;
}
catch ( AuthorizationException e )
{
logError( "Unable to connect to: " + repo.getUrl(), e );
return false;
}
catch ( AbstractMethodError e )
{
log.error( "Wagon " + wagon.getClass().getName() + " does not support the resourceExists method" );
return false;
}
finally
{
try
{
wagon.disconnect();
}
catch ( ConnectionException e )
{
logError( "Error disconnecting wagon - ignored", e );
}
}
}
/**
* Get the Maven project
from the repository depending the Artifact
given.
*
* @param artifact an artifact
* @return the Maven project for the given artifact
* @throws ProjectBuildingException if any
*/
public MavenProject getMavenProjectFromRepository( Artifact artifact )
throws ProjectBuildingException
{
Artifact projectArtifact = artifact;
boolean allowStubModel = false;
if ( !"pom".equals( artifact.getType() ) )
{
projectArtifact = factory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getScope() );
allowStubModel = true;
}
// TODO: we should use the MavenMetadataSource instead
return mavenProjectBuilder.buildFromRepository( projectArtifact, remoteRepositories, localRepository,
allowStubModel );
}
/**
* @param artifact not null
* @param repo not null
* @return the artifact url in the given repo for the given artifact. If it is a snapshot artifact, the version
* will be the timestamp and the build number from the metadata. Could return null if the repo is blacklisted.
*/
public String getDependencyUrlFromRepository( Artifact artifact, ArtifactRepository repo )
{
if ( repo.isBlacklisted() )
{
return null;
}
Artifact copyArtifact = ArtifactUtils.copyArtifact( artifact );
// Try to get the last artifact repo name depending the snapshot version
if ( ( artifact.isSnapshot() && repo.getSnapshots().isEnabled() ) )
{
if ( artifact.getBaseVersion().equals( artifact.getVersion() ) )
{
// Try to resolve it if not already done
if ( artifact.getMetadataList() == null || artifact.getMetadataList().isEmpty() )
{
try
{
resolve( artifact );
}
catch ( ArtifactResolutionException e )
{
log.error( "Artifact: " + artifact.getId() + " could not be resolved." );
}
catch ( ArtifactNotFoundException e )
{
log.error( "Artifact: " + artifact.getId() + " was not found." );
}
}
for ( ArtifactMetadata m : artifact.getMetadataList() )
{
if ( m instanceof SnapshotArtifactRepositoryMetadata )
{
SnapshotArtifactRepositoryMetadata snapshotMetadata = (SnapshotArtifactRepositoryMetadata) m;
Metadata metadata = snapshotMetadata.getMetadata();
Versioning versioning = metadata.getVersioning();
if ( versioning == null || versioning.getSnapshot() == null
|| versioning.getSnapshot().isLocalCopy()
|| versioning.getSnapshot().getTimestamp() == null )
{
continue;
}
// create the version according SnapshotTransformation
String version =
StringUtils.replace( copyArtifact.getVersion(), Artifact.SNAPSHOT_VERSION,
versioning.getSnapshot().getTimestamp() )
+ "-" + versioning.getSnapshot().getBuildNumber();
copyArtifact.setVersion( version );
}
}
}
}
return repo.getUrl() + "/" + repo.pathOf( copyArtifact );
}
// ----------------------------------------------------------------------
// Private methods
// ----------------------------------------------------------------------
/**
* Convenience method to map a Proxy
object from the user system settings to a ProxyInfo
* object.
*
* @return a proxyInfo object instanced or null if no active proxy is define in the settings.xml
*/
private ProxyInfo getProxyInfo()
{
if ( settings == null || settings.getActiveProxy() == null )
{
return null;
}
Proxy settingsProxy = settings.getActiveProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost( settingsProxy.getHost() );
proxyInfo.setType( settingsProxy.getProtocol() );
proxyInfo.setPort( settingsProxy.getPort() );
proxyInfo.setNonProxyHosts( settingsProxy.getNonProxyHosts() );
proxyInfo.setUserName( settingsProxy.getUsername() );
proxyInfo.setPassword( settingsProxy.getPassword() );
return proxyInfo;
}
/**
* Log an error, adding the stacktrace only is debug is enabled.
*
* @param message the error message
* @param e the cause
*/
private void logError( String message, Exception e )
{
if ( log.isDebugEnabled() )
{
log.error( message, e );
}
else
{
log.error( message );
}
}
}
0000775 0000000 0000000 00000000000 11634435442 0035644 5 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer DependenciesRenderer.java 0000664 0000000 0000000 00000154413 11634435442 0042574 0 ustar 00root root 0000000 0000000 maven-project-info-reports-plugin-2.4/src/main/java/org/apache/maven/report/projectinfo/dependencies/renderer package org.apache.maven.report.projectinfo.dependencies.renderer;
/*
* 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.IOException;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.FieldPosition;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.commons.lang.SystemUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.util.HtmlTools;
import org.apache.maven.model.License;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.report.projectinfo.AbstractProjectInfoRenderer;
import org.apache.maven.report.projectinfo.ProjectInfoReportUtils;
import org.apache.maven.report.projectinfo.dependencies.Dependencies;
import org.apache.maven.report.projectinfo.dependencies.DependenciesReportConfiguration;
import org.apache.maven.report.projectinfo.dependencies.RepositoryUtils;
import org.apache.maven.settings.Settings;
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.jar.JarData;
import org.codehaus.plexus.i18n.I18N;
import org.codehaus.plexus.util.StringUtils;
/**
* Renderer the dependencies report.
*
* @version $Id: DependenciesRenderer.java 1103555 2011-05-15 22:08:21Z hboutemy $
* @since 2.1
*/
public class DependenciesRenderer
extends AbstractProjectInfoRenderer
{
/** URL for the 'icon_info_sml.gif' image */
private static final String IMG_INFO_URL = "./images/icon_info_sml.gif";
/** URL for the 'close.gif' image */
private static final String IMG_CLOSE_URL = "./images/close.gif";
/** Random used to generate a UID */
private static final SecureRandom RANDOM;
/** Used to format decimal values in the "Dependency File Details" table */
protected static final DecimalFormat DEFAULT_DECIMAL_FORMAT = new DecimalFormat( "#,##0" );
private static final Set JAR_SUBTYPE;
/**
* An HTML script tag with the Javascript used by the dependencies report.
*/
private static final String JAVASCRIPT;
private final DependencyNode dependencyTreeNode;
private final Dependencies dependencies;
private final DependenciesReportConfiguration configuration;
private final Log log;
private final Settings settings;
private final RepositoryUtils repoUtils;
/** Used to format file length values */
private final DecimalFormat fileLengthDecimalFormat;
/**
* @since 2.1.1
*/
private int section;
/**
* Will be filled with license name / set of projects.
*/
private Map licenseMap = new HashMap()
{
private static final long serialVersionUID = 1L;
/** {@inheritDoc} */
public Object put( String key, Object value )
{
// handle multiple values as a set to avoid duplicates
@SuppressWarnings( "unchecked" )
SortedSet