You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Christopher Hunt <hu...@internode.on.net> on 2010/11/04 23:54:46 UTC

New filter properties - trigger filtering

Hi there,

I'm developing the JavaScript Import Plugin and have come across an issue. I was hoping that someone here can point me in the right direction.

I need to convince the resources plugin that some html resources need to be copied over given new filter properties. My plugin creates filter properties during the generate-resources phase.

Is there a supported method of informing the resources plugin that resources should be re-filtered?

Thanks for any guidance.

Kind regards,
Christopher
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: New filter properties - trigger filtering

Posted by Christopher Hunt <hu...@internode.on.net>.
OK, I think I understand more about what's going on now. I understand that the 4.x maven resources plugin being used by m2e supports the plexus-build-api. As such I think it is receiving a BuildContext implementation provided by m2e that is Eclipse JDT-aware. When the resources plugin is invoked via the command line it appears to be getting a ThreadBuildContext which I presume wraps a DefaultBuildContext, or at least behaves similarly.

When an m2e BuildContext is used only resources that have changed within the IDE will be signalled as changed. When a Thread/DefaultBuildContext is used all resources are assumed to have changed.

I think I'm therefore on the right strategy in terms of updating the BuildContext to signal via refresh() that other resources to be copied. However what I now have to do is figure out how my MOJO gets an m2e BuildContext injected into it... 

I shall ask on the m2e list. Thanks, and I hope that this is helpful to others.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: New filter properties - trigger filtering

Posted by Christopher Hunt <hu...@internode.on.net>.
I'm also starting to wonder if this is actually an m2eclipse thing. If I use the resources plugin 2.3 then all is well within the IDE i.e. resources are always copied (I do not believe that this has anything to do with my interactions with the buildContext). However if 2.4.x is used then m2eclipse looks to be selective w.r.t. the resources that are copied...

Do you know if m2eclipse a) does something special with the resources plugin; and/or (b) perhaps explicitly sets overwrite to false on the plugin?

Kind regards,
Christopher


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: New filter properties - trigger filtering

Posted by Christopher Hunt <hu...@internode.on.net>.
Hi Oliver,

Thanks for your reply. After trawling through the code following on from your pointers, I ended up wondering if I could just inform the build context that these particular html resources had changed (org.sonatype.plexus.build.incremental.BuildContext). I was hoping that this would be enough to cause the files to be re-processed for filtering further down in the process-resources phase. Here's the code I ended up with:

  int htmlFilesRefreshed = 0;
  String htmlExtensions = "html,htm";
  Collection<?> htmlFiles = FileUtils.listFiles( resourceHtmlFolder, htmlExtensions.split( "," ), true );
  for ( Object htmlFileObject : htmlFiles )
  {
    File htmlFile = (File) htmlFileObject;
    buildContext.refresh( htmlFile );
    ++htmlFilesRefreshed;
  }
  if ( htmlFilesRefreshed > 0 )
  {
    getLog().info( "Dependencies changed. " + htmlFilesRefreshed
       + " html file(s) refreshed to enable new <script> insertions." );
  }

The context is declared as:

  /**
   * @component
   */
  private BuildContext buildContext;

Unfortunately, at least within m2eclipse, the above makes no difference as to whether the resources are copied over again in the next phase. Anymore thoughts and guidance? Again, all that I'm trying to do is ensure that my html resources are copied to the target folder again with filtering applied. Thanks for your help.

Kind regards,
Christopher

On 05/11/2010, at 10:12 AM, Olivier Lamy wrote:

> Hi,
> Most of the plugin applying filtering use this [1].
> So you can do this in your mojo. (have a look at the resources plugin
> to see how it works [2])


Re: New filter properties - trigger filtering

Posted by Olivier Lamy <ol...@apache.org>.
Hi,
Most of the plugin applying filtering use this [1].
So you can do this in your mojo. (have a look at the resources plugin
to see how it works [2])

HTH,
-- 
Olivier Lamy
http://twitter.com/olamy
http://www.linkedin.com/in/olamy

[1] http://maven.apache.org/shared/maven-filtering/.
[2] http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java

2010/11/4 Christopher Hunt <hu...@internode.on.net>:
> Hi there,
>
> I'm developing the JavaScript Import Plugin and have come across an issue. I was hoping that someone here can point me in the right direction.
>
> I need to convince the resources plugin that some html resources need to be copied over given new filter properties. My plugin creates filter properties during the generate-resources phase.
>
> Is there a supported method of informing the resources plugin that resources should be re-filtered?
>
> Thanks for any guidance.
>
> Kind regards,
> Christopher
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>



-- 
Olivier Lamy
http://twitter.com/olamy
http://www.linkedin.com/in/olamy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org