You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by jf...@apache.org on 2011/08/20 00:59:56 UTC
svn commit: r1159828 -
/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
Author: jfallows
Date: Sat Aug 20 00:59:56 2011
New Revision: 1159828
URL: http://svn.apache.org/viewvc?rev=1159828&view=rev
Log:
Fix for NPANDAY-461 adds a custom classifier making it easier to deliver both debug and release builds from a single project
Modified:
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1159828&r1=1159827&r2=1159828&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java (original)
+++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java Sat Aug 20 00:59:56 2011
@@ -19,6 +19,7 @@
package npanday.plugin.compile;
+import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
import npanday.PathUtil;
import npanday.vendor.SettingsException;
@@ -38,6 +39,7 @@ import npanday.registry.RepositoryRegist
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
import org.codehaus.plexus.util.FileUtils;
import java.io.BufferedReader;
@@ -100,6 +102,14 @@ public abstract class AbstractCompilerMo
protected MavenProject project;
/**
+ * The maven project helper.
+ *
+ * @component
+ * @required
+ */
+ protected MavenProjectHelper projectHelper;
+
+ /**
* The location of the local Maven repository.
*
* @parameter expression="${settings.localRepository}"
@@ -312,6 +322,11 @@ public abstract class AbstractCompilerMo
protected boolean isDebug;
/**
+ * @parameter classifier;
+ */
+ protected String classifier;
+
+ /**
* @component
*/
protected npanday.executable.NetExecutableFactory netExecutableFactory;
@@ -1119,6 +1134,17 @@ public abstract class AbstractCompilerMo
getCompilerConfig(),
project,
profileAssemblyPath);
+
+ File compiledArtifact = compilerExecutable.getCompiledArtifact();
+
+ // TODO: see issue with CompilerContextImpl.getArtifact(), which does not incorporate outputDirectory
+ if ( outputDirectory != null )
+ {
+ ArtifactType artifactType = getCompilerConfig().getArtifactType();
+ compiledArtifact = new File(outputDirectory.getAbsolutePath() + File.separator +
+ project.getArtifactId() + "." + artifactType.getExtension());
+ }
+
if (!test)
{
// System.Runtime.Versioning.TargetFrameworkAttribute support
@@ -1132,7 +1158,7 @@ public abstract class AbstractCompilerMo
if (isUpToDateWithPomAndSettingsAndDependencies(compilerExecutable.getCompiledArtifact()))
{
getLog().info("NPANDAY-900-003: Nothing to compile - all classes are up-to-date");
- project.getArtifact().setFile(compilerExecutable.getCompiledArtifact());
+ attachArtifact(compiledArtifact, classifier);
return;
}
}
@@ -1152,7 +1178,7 @@ public abstract class AbstractCompilerMo
if (!test)
{
- project.getArtifact().setFile(compilerExecutable.getCompiledArtifact());
+ attachArtifact(compiledArtifact, classifier);
}
}
@@ -1171,6 +1197,19 @@ public abstract class AbstractCompilerMo
getLog().info("Mojo Execution Time = " + (endTime - startTime));
}
+ private void attachArtifact(File artifact, String classifier) {
+ if ( classifier != null )
+ {
+ getLog().debug("Attaching artifact " + artifact.getPath() + " with classifier: " + classifier);
+ projectHelper.attachArtifact(project, artifact, classifier);
+ }
+ else
+ {
+ getLog().debug("Attaching default project artifact " + artifact.getPath());
+ project.getArtifact().setFile(artifact);
+ }
+ }
+
protected abstract void initializeDefaults() throws MojoExecutionException;
Re: copy dependencies plugin fails with npanday
Posted by Brett Porter <br...@apache.org>.
Sorry, this is a known issue:
https://issues.apache.org/jira/browse/NPANDAY-98
On 13/09/2011, at 7:40 AM, Sergio Rupena wrote:
> Hi,
>
> I have a multi module build pom with 3 modules. Each module inherits
> from the parent pom.
>
> Parent
> ProjectA (dotnet-library)
> ProjectB (dotnet-library , depends on ProjectA)
> ProjectC (dotnet-library , depends on ProjectB and uses
> maven-dependency-plugin plugin)
>
> * All 3 child poms inherit group id and version from the parent pom
> * the version-dependencies between the projects are declared using a
> property: <version>${project.version}</version>
>
> Using this minimal setup I can successfully compile the projects. As
> soon as I add maven's maven-dependency-plugin plugin I get compile
> errors. I was not sure if this behavior was related to npanday (1.4.0)
> or is a general issue with maven (3.0.3), so I made a test. In plain
> java there is no problem, so it seems to be related to npanday.
>
> The error looks as follows:
>
> [ERROR] Failed to execute goal on project ProjectC: Could not resolve
> dependencies for project
> MavenDependencies:ProjectC:dotnet-library:1.0-SNAPSHOT: Could not find
> artifact MavenDependencies:ProjectA:dll:${project.version} in central
> (http://artifactory:8081/artifactory/libs-releases) -> [Help 1]
>
> I want to mention the following things:
>
> * It's obvious that the expression ${project.version} failed to evaluate
> to 1.0-SNAPSHOT
> * in my local repository the following folder pops up:
> ProjectA\${project.version}
> * This error only occurs if there are at least 3 projects (if project B
> uses the dependency plugin, it works)
> * if project dependencies are explicit (1.0-SNAPSHOT), then everything
> works fine.
>
>
> With the current version of npanday it does not seem possible to put the
> information like the 'version' to the parent pom, as other unrelated
> plugins will just fail.
>
>
> Best regards,
> Sergio
>
>
> PARENT POM:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>MavenDependencies</groupId>
> <artifactId>Parent</artifactId>
> <packaging>pom</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>PARENT POM</name>
> <build>
> <sourceDirectory>src/main</sourceDirectory>
> <plugins>
> <plugin>
> <!-- Include npanday and configure it.-->
> <groupId>org.apache.npanday.plugins</groupId>
> <artifactId>maven-compile-plugin</artifactId>
> <version>1.4.0-incubating</version>
> <extensions>true</extensions>
> </plugin>
> </plugins>
> </build>
> <modules>
> <module>ProjectA</module>
> <module>ProjectB</module>
> <module>ProjectC</module>
> </modules>
> </project>
>
>
> PROJECT A:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <parent>
> <groupId>MavenDependencies</groupId>
> <artifactId>Parent</artifactId>
> <version>1.0-SNAPSHOT</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <groupId>MavenDependencies</groupId>
> <artifactId>ProjectA</artifactId>
> <packaging>dotnet-library</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>Project A</name>
> </project>
>
>
> PROJECT B:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <parent>
> <groupId>MavenDependencies</groupId>
> <artifactId>Parent</artifactId>
> <version>1.0-SNAPSHOT</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <packaging>dotnet-library</packaging>
> <artifactId>ProjectB</artifactId>
> <name>Project B</name>
>
> <dependencies>
> <dependency>
> <groupId>MavenDependencies</groupId>
> <artifactId>ProjectA</artifactId>
> <version>${project.version}</version>
> <type>dotnet-library</type>
> </dependency>
> </dependencies>
> </project>
>
>
> PROJECT C:
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <parent>
> <groupId>MavenDependencies</groupId>
> <artifactId>Parent</artifactId>
> <version>1.0-SNAPSHOT</version>
> </parent>
> <modelVersion>4.0.0</modelVersion>
> <packaging>dotnet-library</packaging>
> <artifactId>ProjectC</artifactId>
> <name>Project C</name>
> <build>
> <plugins>
> <!-- IF YOU REMOVE THIS PLUGIN, IT WILL COMPILE WITH NPANDAY-->
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-dependency-plugin</artifactId>
> <extensions>true</extensions>
> <version>2.3</version>
> <executions>
> <execution>
> <id>copy-dependencies</id>
> <phase>validate</phase>
> <goals>
> <goal>copy-dependencies</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> </plugins>
> </build>
> <dependencies>
> <dependency>
> <groupId>MavenDependencies</groupId>
> <artifactId>ProjectB</artifactId>
> <version>${project.version}</version>
> <type>dotnet-library</type>
> </dependency>
> </dependencies>
> </project>
>
--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/
http://au.linkedin.com/in/brettporter
copy dependencies plugin fails with npanday
Posted by Sergio Rupena <sr...@247e.com>.
Hi,
I have a multi module build pom with 3 modules. Each module inherits
from the parent pom.
Parent
ProjectA (dotnet-library)
ProjectB (dotnet-library , depends on ProjectA)
ProjectC (dotnet-library , depends on ProjectB and uses
maven-dependency-plugin plugin)
* All 3 child poms inherit group id and version from the parent pom
* the version-dependencies between the projects are declared using a
property: <version>${project.version}</version>
Using this minimal setup I can successfully compile the projects. As
soon as I add maven's maven-dependency-plugin plugin I get compile
errors. I was not sure if this behavior was related to npanday (1.4.0)
or is a general issue with maven (3.0.3), so I made a test. In plain
java there is no problem, so it seems to be related to npanday.
The error looks as follows:
[ERROR] Failed to execute goal on project ProjectC: Could not resolve
dependencies for project
MavenDependencies:ProjectC:dotnet-library:1.0-SNAPSHOT: Could not find
artifact MavenDependencies:ProjectA:dll:${project.version} in central
(http://artifactory:8081/artifactory/libs-releases) -> [Help 1]
I want to mention the following things:
* It's obvious that the expression ${project.version} failed to evaluate
to 1.0-SNAPSHOT
* in my local repository the following folder pops up:
ProjectA\${project.version}
* This error only occurs if there are at least 3 projects (if project B
uses the dependency plugin, it works)
* if project dependencies are explicit (1.0-SNAPSHOT), then everything
works fine.
With the current version of npanday it does not seem possible to put the
information like the 'version' to the parent pom, as other unrelated
plugins will just fail.
Best regards,
Sergio
PARENT POM:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MavenDependencies</groupId>
<artifactId>Parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>PARENT POM</name>
<build>
<sourceDirectory>src/main</sourceDirectory>
<plugins>
<plugin>
<!-- Include npanday and configure it.-->
<groupId>org.apache.npanday.plugins</groupId>
<artifactId>maven-compile-plugin</artifactId>
<version>1.4.0-incubating</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<modules>
<module>ProjectA</module>
<module>ProjectB</module>
<module>ProjectC</module>
</modules>
</project>
PROJECT A:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>MavenDependencies</groupId>
<artifactId>Parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>MavenDependencies</groupId>
<artifactId>ProjectA</artifactId>
<packaging>dotnet-library</packaging>
<version>1.0-SNAPSHOT</version>
<name>Project A</name>
</project>
PROJECT B:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>MavenDependencies</groupId>
<artifactId>Parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>dotnet-library</packaging>
<artifactId>ProjectB</artifactId>
<name>Project B</name>
<dependencies>
<dependency>
<groupId>MavenDependencies</groupId>
<artifactId>ProjectA</artifactId>
<version>${project.version}</version>
<type>dotnet-library</type>
</dependency>
</dependencies>
</project>
PROJECT C:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>MavenDependencies</groupId>
<artifactId>Parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>dotnet-library</packaging>
<artifactId>ProjectC</artifactId>
<name>Project C</name>
<build>
<plugins>
<!-- IF YOU REMOVE THIS PLUGIN, IT WILL COMPILE WITH NPANDAY-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<extensions>true</extensions>
<version>2.3</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>validate</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>MavenDependencies</groupId>
<artifactId>ProjectB</artifactId>
<version>${project.version}</version>
<type>dotnet-library</type>
</dependency>
</dependencies>
</project>
Re: svn commit: r1159828 - /incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
Posted by Lars Corneliussen <me...@lcorneliussen.de>.
thanks, nice! :)
--
Message sent from mobile device
Am 08.09.2011 um 06:20 schrieb John Fallows <jo...@kaazing.com>:
> Lars,
>
> It is necessary to execute the compiler in two separate configurations to
> produce both Debug and Release libraries, so a classifier is necessary in
> one of those cases to avoid overwriting the default project artifact.
>
> We use this technique with a separate NPanday maven-compiler-plugin
> execution to generate the Debug build with the "debug" classifier such that
> both Debug and Release artifacts can be shipped with the final product.
>
> tc,
> -john.
>
> On Sun, Aug 28, 2011 at 11:06 PM, Lars Corneliussen <me...@lcorneliussen.de>wrote:
>
>> Can you elaborate more on how this works? Would you then have to alter the
>> pom for debug-compiles?
>>
>> Am 20.08.11 02:59, schrieb jfallows@apache.org:
>>
>>> Author: jfallows
>>> Date: Sat Aug 20 00:59:56 2011
>>> New Revision: 1159828
>>>
>>> URL: http://svn.apache.org/viewvc?**rev=1159828&view=rev<http://svn.apache.org/viewvc?rev=1159828&view=rev>
>>> Log:
>>> Fix for NPANDAY-461 adds a custom classifier making it easier to deliver
>>> both debug and release builds from a single project
>>>
>>> Modified:
>>> incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java
>>>
>>> Modified: incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java
>>> URL: http://svn.apache.org/viewvc/**incubator/npanday/trunk/**
>>> plugins/maven-compile-plugin/**src/main/java/npanday/plugin/**
>>> compile/AbstractCompilerMojo.**java?rev=1159828&r1=1159827&**
>>> r2=1159828&view=diff<http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1159828&r1=1159827&r2=1159828&view=diff>
>>> ==============================**==============================**
>>> ==================
>>> --- incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java
>>> (original)
>>> +++ incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java Sat
>>> Aug 20 00:59:56 2011
>>> @@ -19,6 +19,7 @@
>>>
>>> package npanday.plugin.compile;
>>>
>>> +import npanday.ArtifactType;
>>> import npanday.ArtifactTypeHelper;
>>> import npanday.PathUtil;
>>> import npanday.vendor.**SettingsException;
>>> @@ -38,6 +39,7 @@ import npanday.registry.**RepositoryRegist
>>> import org.apache.maven.plugin.**AbstractMojo;
>>> import org.apache.maven.plugin.**MojoExecutionException;
>>> import org.apache.maven.project.**MavenProject;
>>> +import org.apache.maven.project.**MavenProjectHelper;
>>> import org.codehaus.plexus.util.**FileUtils;
>>>
>>> import java.io.BufferedReader;
>>> @@ -100,6 +102,14 @@ public abstract class AbstractCompilerMo
>>> protected MavenProject project;
>>>
>>> /**
>>> + * The maven project helper.
>>> + *
>>> + * @component
>>> + * @required
>>> + */
>>> + protected MavenProjectHelper projectHelper;
>>> +
>>> + /**
>>> * The location of the local Maven repository.
>>> *
>>> * @parameter expression="${settings.**localRepository}"
>>> @@ -312,6 +322,11 @@ public abstract class AbstractCompilerMo
>>> protected boolean isDebug;
>>>
>>> /**
>>> + * @parameter classifier;
>>> + */
>>> + protected String classifier;
>>> +
>>> + /**
>>> * @component
>>> */
>>> protected npanday.executable.**NetExecutableFactory
>>> netExecutableFactory;
>>> @@ -1119,6 +1134,17 @@ public abstract class AbstractCompilerMo
>>> getCompilerConfig(),
>>> project,
>>> profileAssemblyPath);
>>> +
>>> + File compiledArtifact = compilerExecutable.**
>>> getCompiledArtifact();
>>> +
>>> + // TODO: see issue with CompilerContextImpl.**getArtifact(),
>>> which does not incorporate outputDirectory
>>> + if ( outputDirectory != null )
>>> + {
>>> + ArtifactType artifactType = getCompilerConfig().**
>>> getArtifactType();
>>> + compiledArtifact = new File(outputDirectory.**getAbsolutePath()
>>> + File.separator +
>>> + project.getArtifactId() + "."
>>> + artifactType.getExtension());
>>> + }
>>> +
>>> if (!test)
>>> {
>>> // System.Runtime.Versioning.**TargetFrameworkAttribute
>>> support
>>> @@ -1132,7 +1158,7 @@ public abstract class AbstractCompilerMo
>>> if (**isUpToDateWithPomAndSettingsAn**dDependencies(
>>> **compilerExecutable.**getCompiledArtifact()))
>>> {
>>> getLog().info("NPANDAY-900-**003: Nothing to
>>> compile - all classes are up-to-date");
>>> - project.getArtifact().setFile(**
>>> compilerExecutable.**getCompiledArtifact());
>>> + attachArtifact(**compiledArtifact, classifier);
>>> return;
>>> }
>>> }
>>> @@ -1152,7 +1178,7 @@ public abstract class AbstractCompilerMo
>>>
>>> if (!test)
>>> {
>>> - project.getArtifact().setFile(**compilerExecutable.**
>>> getCompiledArtifact());
>>> + attachArtifact(**compiledArtifact, classifier);
>>> }
>>>
>>> }
>>> @@ -1171,6 +1197,19 @@ public abstract class AbstractCompilerMo
>>> getLog().info("Mojo Execution Time = " + (endTime - startTime));
>>> }
>>>
>>> + private void attachArtifact(File artifact, String classifier) {
>>> + if ( classifier != null )
>>> + {
>>> + getLog().debug("Attaching artifact " + artifact.getPath() + "
>>> with classifier: " + classifier);
>>> + projectHelper.attachArtifact(**project, artifact,
>>> classifier);
>>> + }
>>> + else
>>> + {
>>> + getLog().debug("Attaching default project artifact " +
>>> artifact.getPath());
>>> + project.getArtifact().setFile(**artifact);
>>> + }
>>> + }
>>> +
>>>
>>> protected abstract void initializeDefaults() throws
>>> MojoExecutionException;
>>>
>>>
>>>
>>>
>>
>
>
> --
>> |< Kaazing Corporation >|<
> John Fallows | CTO | +1.650.960.8148
> 444 Castro St, Suite 1100 | Mountain View, CA 94041, USA
Re: svn commit: r1159828 - /incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
Posted by John Fallows <jo...@kaazing.com>.
Lars,
It is necessary to execute the compiler in two separate configurations to
produce both Debug and Release libraries, so a classifier is necessary in
one of those cases to avoid overwriting the default project artifact.
We use this technique with a separate NPanday maven-compiler-plugin
execution to generate the Debug build with the "debug" classifier such that
both Debug and Release artifacts can be shipped with the final product.
tc,
-john.
On Sun, Aug 28, 2011 at 11:06 PM, Lars Corneliussen <me...@lcorneliussen.de>wrote:
> Can you elaborate more on how this works? Would you then have to alter the
> pom for debug-compiles?
>
> Am 20.08.11 02:59, schrieb jfallows@apache.org:
>
>> Author: jfallows
>> Date: Sat Aug 20 00:59:56 2011
>> New Revision: 1159828
>>
>> URL: http://svn.apache.org/viewvc?**rev=1159828&view=rev<http://svn.apache.org/viewvc?rev=1159828&view=rev>
>> Log:
>> Fix for NPANDAY-461 adds a custom classifier making it easier to deliver
>> both debug and release builds from a single project
>>
>> Modified:
>> incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java
>>
>> Modified: incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java
>> URL: http://svn.apache.org/viewvc/**incubator/npanday/trunk/**
>> plugins/maven-compile-plugin/**src/main/java/npanday/plugin/**
>> compile/AbstractCompilerMojo.**java?rev=1159828&r1=1159827&**
>> r2=1159828&view=diff<http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1159828&r1=1159827&r2=1159828&view=diff>
>> ==============================**==============================**
>> ==================
>> --- incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java
>> (original)
>> +++ incubator/npanday/trunk/**plugins/maven-compile-plugin/**
>> src/main/java/npanday/plugin/**compile/AbstractCompilerMojo.**java Sat
>> Aug 20 00:59:56 2011
>> @@ -19,6 +19,7 @@
>>
>> package npanday.plugin.compile;
>>
>> +import npanday.ArtifactType;
>> import npanday.ArtifactTypeHelper;
>> import npanday.PathUtil;
>> import npanday.vendor.**SettingsException;
>> @@ -38,6 +39,7 @@ import npanday.registry.**RepositoryRegist
>> import org.apache.maven.plugin.**AbstractMojo;
>> import org.apache.maven.plugin.**MojoExecutionException;
>> import org.apache.maven.project.**MavenProject;
>> +import org.apache.maven.project.**MavenProjectHelper;
>> import org.codehaus.plexus.util.**FileUtils;
>>
>> import java.io.BufferedReader;
>> @@ -100,6 +102,14 @@ public abstract class AbstractCompilerMo
>> protected MavenProject project;
>>
>> /**
>> + * The maven project helper.
>> + *
>> + * @component
>> + * @required
>> + */
>> + protected MavenProjectHelper projectHelper;
>> +
>> + /**
>> * The location of the local Maven repository.
>> *
>> * @parameter expression="${settings.**localRepository}"
>> @@ -312,6 +322,11 @@ public abstract class AbstractCompilerMo
>> protected boolean isDebug;
>>
>> /**
>> + * @parameter classifier;
>> + */
>> + protected String classifier;
>> +
>> + /**
>> * @component
>> */
>> protected npanday.executable.**NetExecutableFactory
>> netExecutableFactory;
>> @@ -1119,6 +1134,17 @@ public abstract class AbstractCompilerMo
>> getCompilerConfig(),
>> project,
>> profileAssemblyPath);
>> +
>> + File compiledArtifact = compilerExecutable.**
>> getCompiledArtifact();
>> +
>> + // TODO: see issue with CompilerContextImpl.**getArtifact(),
>> which does not incorporate outputDirectory
>> + if ( outputDirectory != null )
>> + {
>> + ArtifactType artifactType = getCompilerConfig().**
>> getArtifactType();
>> + compiledArtifact = new File(outputDirectory.**getAbsolutePath()
>> + File.separator +
>> + project.getArtifactId() + "."
>> + artifactType.getExtension());
>> + }
>> +
>> if (!test)
>> {
>> // System.Runtime.Versioning.**TargetFrameworkAttribute
>> support
>> @@ -1132,7 +1158,7 @@ public abstract class AbstractCompilerMo
>> if (**isUpToDateWithPomAndSettingsAn**dDependencies(
>> **compilerExecutable.**getCompiledArtifact()))
>> {
>> getLog().info("NPANDAY-900-**003: Nothing to
>> compile - all classes are up-to-date");
>> - project.getArtifact().setFile(**
>> compilerExecutable.**getCompiledArtifact());
>> + attachArtifact(**compiledArtifact, classifier);
>> return;
>> }
>> }
>> @@ -1152,7 +1178,7 @@ public abstract class AbstractCompilerMo
>>
>> if (!test)
>> {
>> - project.getArtifact().setFile(**compilerExecutable.**
>> getCompiledArtifact());
>> + attachArtifact(**compiledArtifact, classifier);
>> }
>>
>> }
>> @@ -1171,6 +1197,19 @@ public abstract class AbstractCompilerMo
>> getLog().info("Mojo Execution Time = " + (endTime - startTime));
>> }
>>
>> + private void attachArtifact(File artifact, String classifier) {
>> + if ( classifier != null )
>> + {
>> + getLog().debug("Attaching artifact " + artifact.getPath() + "
>> with classifier: " + classifier);
>> + projectHelper.attachArtifact(**project, artifact,
>> classifier);
>> + }
>> + else
>> + {
>> + getLog().debug("Attaching default project artifact " +
>> artifact.getPath());
>> + project.getArtifact().setFile(**artifact);
>> + }
>> + }
>> +
>>
>> protected abstract void initializeDefaults() throws
>> MojoExecutionException;
>>
>>
>>
>>
>
--
>|< Kaazing Corporation >|<
John Fallows | CTO | +1.650.960.8148
444 Castro St, Suite 1100 | Mountain View, CA 94041, USA
Re: svn commit: r1159828 - /incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
Posted by Lars Corneliussen <me...@lcorneliussen.de>.
Can you elaborate more on how this works? Would you then have to alter
the pom for debug-compiles?
Am 20.08.11 02:59, schrieb jfallows@apache.org:
> Author: jfallows
> Date: Sat Aug 20 00:59:56 2011
> New Revision: 1159828
>
> URL: http://svn.apache.org/viewvc?rev=1159828&view=rev
> Log:
> Fix for NPANDAY-461 adds a custom classifier making it easier to deliver both debug and release builds from a single project
>
> Modified:
> incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
>
> Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
> URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1159828&r1=1159827&r2=1159828&view=diff
> ==============================================================================
> --- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java (original)
> +++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java Sat Aug 20 00:59:56 2011
> @@ -19,6 +19,7 @@
>
> package npanday.plugin.compile;
>
> +import npanday.ArtifactType;
> import npanday.ArtifactTypeHelper;
> import npanday.PathUtil;
> import npanday.vendor.SettingsException;
> @@ -38,6 +39,7 @@ import npanday.registry.RepositoryRegist
> import org.apache.maven.plugin.AbstractMojo;
> import org.apache.maven.plugin.MojoExecutionException;
> import org.apache.maven.project.MavenProject;
> +import org.apache.maven.project.MavenProjectHelper;
> import org.codehaus.plexus.util.FileUtils;
>
> import java.io.BufferedReader;
> @@ -100,6 +102,14 @@ public abstract class AbstractCompilerMo
> protected MavenProject project;
>
> /**
> + * The maven project helper.
> + *
> + * @component
> + * @required
> + */
> + protected MavenProjectHelper projectHelper;
> +
> + /**
> * The location of the local Maven repository.
> *
> * @parameter expression="${settings.localRepository}"
> @@ -312,6 +322,11 @@ public abstract class AbstractCompilerMo
> protected boolean isDebug;
>
> /**
> + * @parameter classifier;
> + */
> + protected String classifier;
> +
> + /**
> * @component
> */
> protected npanday.executable.NetExecutableFactory netExecutableFactory;
> @@ -1119,6 +1134,17 @@ public abstract class AbstractCompilerMo
> getCompilerConfig(),
> project,
> profileAssemblyPath);
> +
> + File compiledArtifact = compilerExecutable.getCompiledArtifact();
> +
> + // TODO: see issue with CompilerContextImpl.getArtifact(), which does not incorporate outputDirectory
> + if ( outputDirectory != null )
> + {
> + ArtifactType artifactType = getCompilerConfig().getArtifactType();
> + compiledArtifact = new File(outputDirectory.getAbsolutePath() + File.separator +
> + project.getArtifactId() + "." + artifactType.getExtension());
> + }
> +
> if (!test)
> {
> // System.Runtime.Versioning.TargetFrameworkAttribute support
> @@ -1132,7 +1158,7 @@ public abstract class AbstractCompilerMo
> if (isUpToDateWithPomAndSettingsAndDependencies(compilerExecutable.getCompiledArtifact()))
> {
> getLog().info("NPANDAY-900-003: Nothing to compile - all classes are up-to-date");
> - project.getArtifact().setFile(compilerExecutable.getCompiledArtifact());
> + attachArtifact(compiledArtifact, classifier);
> return;
> }
> }
> @@ -1152,7 +1178,7 @@ public abstract class AbstractCompilerMo
>
> if (!test)
> {
> - project.getArtifact().setFile(compilerExecutable.getCompiledArtifact());
> + attachArtifact(compiledArtifact, classifier);
> }
>
> }
> @@ -1171,6 +1197,19 @@ public abstract class AbstractCompilerMo
> getLog().info("Mojo Execution Time = " + (endTime - startTime));
> }
>
> + private void attachArtifact(File artifact, String classifier) {
> + if ( classifier != null )
> + {
> + getLog().debug("Attaching artifact " + artifact.getPath() + " with classifier: " + classifier);
> + projectHelper.attachArtifact(project, artifact, classifier);
> + }
> + else
> + {
> + getLog().debug("Attaching default project artifact " + artifact.getPath());
> + project.getArtifact().setFile(artifact);
> + }
> + }
> +
>
> protected abstract void initializeDefaults() throws MojoExecutionException;
>
>
>