How to trigger Pre-Build events with NPanday

Aug 6, 2010 at 6:01 PM

There is a requirement to have the Pre-Build events to be triggered before compilation.

The example which we are working on has MSBuid configured with the  pre-build events .(This pre build events generates the ".dll" from the ".js" file. This generated dll is being referred in the Project as one of the dependency.)

Please let me know if anyone aware about the way we can do this in NPanday. (may be using some NPanday plugin)


Aug 9, 2010 at 1:27 AM

The compile goal runs in the compile maven phase. Typically, you'd do this sort of thing in an earlier phase, like generate-sources.

However, we don't have a way to get the current msbuild plugin to just trigger this part of the file for you.

There are a couple of avenues to explore:

  1. write an npanday plugin for whatever tool does the js -> dll conversion and use it before the compile plugin
  2. convert the project to delegate to the msbuild configuration for the project

which sounds closer to what you want?

Aug 9, 2010 at 12:26 PM

thanks for reply..

Sorry but could not understand the option 2 as how to delegate to the msbuild configuration..

Anyway will try to work on option 1 to write an npanday plugin.




Aug 9, 2010 at 2:04 PM
option 2 would mean declaring the project as <packaging>pom</packaging> instead of a library, then using the msbuild plugin to run the normal build, then using the buildhelper maven plugin to attach the artifacts you want deployed. This is a common pattern in Maven for handling ZIP/TAR binary archives and can be seen in the NPanday code for the repository builder, or the MSI.
Aug 11, 2010 at 8:04 PM
Edited Aug 11, 2010 at 8:09 PM

Hi, I am working on to create the plugin (as mentioned in the above comments).

This plugin suppose to generate the .dll file using "jsc" tool before the compilation phase. The generated ".dll" file is created at prespecified location ("${project.basedir}") so that it can be specify in advance in the POM file as a project dependency.

 I already wrote code to performed the above steps. the plugin goal is configured to run at generate-sources phase. (so that new .dll would be generated before the compilation) It works fine if old copy of dynamic .dll is already present in the ("${project.basedir}") directory. ( this dynamic dll is specified in POM as system type dependency)

However NPanday Build of project (which uses this plugin) gives an direct error at compilation phase if that dependency is not present already at "${project.basedir}" (not first executing first plugin goal with generate-sources lifecycle)

According to my understading an NPanday execution should first execute the new plugin goal (Attached to generate-source phase) before the compilation phase. which is not happening with this custom plugin.

Not sure is this the right forum to put forward the plugin question but thought of continuing the ongoing discussion here.

Aug 12, 2010 at 4:59 AM

If I've understood correctly, you've set a dependency in the current project to this new artifact also built within the project using <systemPath> to refer to the target directory. This generally won't work as the dependencies get resolved before the project build is run in most cases, so it becomes a chicken and egg problem.

You could either:

  1. separate the generated code into a separate module that produces the dll, then express a dependency on that module
  2. build it in the same project, but not express a dependency, then pass it into the compile plugin explicitly and deploy it to the repository with a classifier. It is effectively an "internal" dependency to be used in compilation and can be made available, but it's not going to be automatically handled by Maven's dependency mechanism if other projects happen to want to consume them together.

Both can work in either case, but the first is more suited to situation where the new DLL needs to be used outside the current project, while the second is best when you only need to use it in the process of building the main artifact.

Aug 12, 2010 at 9:27 PM


I could make it work by following ideas from the second option.

Instead of specifying the reference in the dependecies section , supplied it as parameters to "maven-compile-plugin" .. (ie vbc compiler option as /.reference:.\[name of the dynamic dll])/

Thanks brett for suggestion.