Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 95514 invoked from network); 17 Nov 2010 21:59:07 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 17 Nov 2010 21:59:07 -0000 Received: (qmail 7516 invoked by uid 500); 17 Nov 2010 21:59:38 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 7426 invoked by uid 500); 17 Nov 2010 21:59:37 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 7329 invoked by uid 99); 17 Nov 2010 21:59:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Nov 2010 21:59:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Nov 2010 21:59:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 30CAB238890D; Wed, 17 Nov 2010 21:58:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1036245 - /maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java Date: Wed, 17 Nov 2010 21:58:23 -0000 To: commits@maven.apache.org From: vsiveton@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101117215823.30CAB238890D@eris.apache.org> Author: vsiveton Date: Wed Nov 17 21:58:22 2010 New Revision: 1036245 URL: http://svn.apache.org/viewvc?rev=1036245&view=rev Log: [MPIR-80] added minimum JDK Rev to project summary o display JDK rev only if the project seems a Java project Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java Modified: maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java?rev=1036245&r1=1036244&r2=1036245&view=diff ============================================================================== --- maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java (original) +++ maven/plugins/trunk/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ProjectSummaryReport.java Wed Nov 17 21:58:22 2010 @@ -21,10 +21,14 @@ package org.apache.maven.report.projecti import org.apache.maven.doxia.sink.Sink; 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; /** @@ -86,7 +90,7 @@ public class ProjectSummaryReport { startSection( getTitle() ); - //general information sub-section + // general information sub-section String name = project.getName(); if ( name == null ) { @@ -112,7 +116,7 @@ public class ProjectSummaryReport endTable(); endSection(); - //organization sub-section + // organization sub-section startSection( getI18nString( "organization.title" ) ); Organization organization = project.getOrganization(); if ( organization == null ) @@ -138,7 +142,7 @@ public class ProjectSummaryReport } endSection(); - //build section + // build section startSection( getI18nString( "build.title" ) ); startTable(); tableHeader( new String[] { getI18nString( "field" ), getI18nString( "value" ) } ); @@ -146,7 +150,10 @@ public class ProjectSummaryReport tableRow( new String[] { getI18nString( "build.artifactid" ), project.getArtifactId() } ); tableRow( new String[] { getI18nString( "build.version" ), project.getVersion() } ); tableRow( new String[] { getI18nString( "build.type" ), project.getPackaging() } ); - tableRow( new String[] { getI18nString( "build.jdk" ), getMinimumJavaVersion() } ); + if ( isJavaProject( project ) ) + { + tableRow( new String[] { getI18nString( "build.jdk" ), getMinimumJavaVersion() } ); + } endTable(); endSection(); @@ -249,5 +256,50 @@ public class ProjectSummaryReport 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" ) ) + { + return true; + } + + // java files in the source directory? + try + { + if ( FileUtils.getFileNames( new File( project.getBuild().getSourceDirectory() ), "**/*.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; + } } }