diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java | 14 | ||||
-rw-r--r-- | src/main/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 @@ -48,6 +48,11 @@ public class NarInfo 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; this.version = version; @@ -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 ); + } } } |