From 961b66693792efe0f1d3d28c7f844e94728c3057 Mon Sep 17 00:00:00 2001 From: Volker Schumacher Date: Thu, 28 Jan 2010 11:12:59 +0800 Subject: fixed loading of custom nar.properties --- .../maven/plugin/nar/AbstractCompileMojo.java | 14 +++++++--- .../java/org/apache/maven/plugin/nar/NarInfo.java | 30 +++++++++++++--------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java index 876f152..cf3e2a0 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java @@ -267,9 +267,17 @@ public abstract class AbstractCompileMojo { if ( narInfo == null ) { - narInfo = - new NarInfo( getMavenProject().getGroupId(), getMavenProject().getArtifactId(), - getMavenProject().getVersion(), getLog() ); + String groupId = getMavenProject().getGroupId(); + String artifactId = getMavenProject().getArtifactId(); + + File propertiesDir = new File( getMavenProject().getBasedir(), "src/main/resources/META-INF/nar/" + groupId + "/" + artifactId ); + File propertiesFile = new File( propertiesDir, NarInfo.NAR_PROPERTIES ); + + narInfo = new NarInfo( + groupId, artifactId, + getMavenProject().getVersion(), + getLog(), + propertiesFile ); } return narInfo; } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarInfo.java b/src/main/java/org/apache/maven/plugin/nar/NarInfo.java index 504d44e..9337ea3 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarInfo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarInfo.java @@ -47,6 +47,11 @@ public class NarInfo private Log log; public NarInfo( String groupId, String artifactId, String version, Log log ) throws MojoExecutionException + { + this( groupId, artifactId, version, log, null ); + } + + public NarInfo( String groupId, String artifactId, String version, Log log, File propertiesFile ) throws MojoExecutionException { this.groupId = groupId; this.artifactId = artifactId; @@ -55,19 +60,20 @@ public class NarInfo info = new Properties(); // Fill with general properties.nar file - File propertiesDir = new File( "src/main/resources/META-INF/nar/" + groupId + "/" + artifactId ); - File propertiesFile = new File( propertiesDir, NarInfo.NAR_PROPERTIES ); - try - { - info.load( new FileInputStream( propertiesFile ) ); - } - catch ( FileNotFoundException e ) - { - // ignored - } - catch ( IOException e ) + if( propertiesFile != null ) { - throw new MojoExecutionException( "Problem loading "+propertiesFile, e ); + try + { + info.load( new FileInputStream( propertiesFile ) ); + } + catch ( FileNotFoundException e ) + { + // ignored + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Problem loading "+propertiesFile, e ); + } } } -- cgit v1.2.3