los ejemplos de la definición común de plexo components.xml deben conseguirle comenzado:the stock definition examples from plexus components.xml should get you started:
http://plexus.codehaus.org/guides/developer-guide/configuration/component-descriptor.html Saludos Cordiales desde Sud America/Cordial Salutations Martín ______________________ > Date: Wed, 20 Aug 2014 10:12:36 -0700 > From: [email protected] > Subject: Re: creating custom Maven resource filter > To: [email protected] > > Ok its figured out. Had to write my own MavenFileFilter and use plexus to > wire it in. > > The only question I now have is how to set the role-hint for our custom > MavenFileFilter in a pom file? To have our custom MavenFileFilter be wired > in I stole the role-hint "default". But I would like to use my own role-hint > because there is another "default" implementation and I do not want it to use > that one. I do not know if it is by chance that our implementation is being > used. > > For the MavenResourcesFiltering I was able to set the role-hint the > mavenFilteringHints tag. I guess what I am asking for is the equivalent tag > for setting the MavenFileFilter implementation? > > thanks > > jose > > > On Wednesday, August 20, 2014 10:02 AM, Jose Martinez <[email protected]> > wrote: > > > > Cool, thanks Robert. > > So now that I have the plugin functioning and my MavenResourcesFiltering's > filterResources(mre) method being called, what can I do with the > MavenResourcesExecution to access the ${propertyNames} in my resources and > set their values? > > I pulled the List<Resource> from the MavenResourcesExecution, but I can't > figure out how to get the ${propertyNames} from my resources or set their > values? > > thanks > jose > > > On Tuesday, August 19, 2014 4:21 PM, Robert Scholte <[email protected]> > wrote: > > > > Done, see MRESOURCES-182[1] > Will be updated with the next release. > > thanks, > Robert > > [1] https://jira.codehaus.org/browse/MRESOURCES-182 > > Op Tue, 19 Aug 2014 21:43:44 +0200 schreef Jose Martinez > <[email protected]>: > > > Problem resolved. The documentation in this link has the dependency > > tags in the wrong place... > > http://maven.apache.org/plugins/maven-resources-plugin/examples/custom-resource-filters.html#Dependency_declaration > > When I moved the plugin's dependencies tag outside of the configuration > > tags then everything worked. Who ever manages that link please > > investigate. Everything else on the site was spot on. > > thanks > > jose > > > > > > On Tuesday, August 19, 2014 2:46 PM, Jose Martinez <[email protected]> > > wrote: > > > > > > Hello, > > > > I've > made some progress on this and have a problem with Maven finding my > > custom plugin's class. > > > > ============= > > [ERROR] Failed to execute goal > > org.apache.maven.plugins:maven-resources-plugin:2.6:resources > > (default-resources) on project roc: java.util.NoSuchElementException > > [ERROR] role: org.apache.maven.shared.filtering.MavenResourcesFiltering > > [ERROR] roleHint: ResourceFilter [ERROR] -> [Help 1] > > ============= > > > > I created a class that implements MavenResourcesFiltering, and added the > > plexus javadoc comments as instructed. ============= > > /** > > * > > * @author jmartinez > > * > > * @plexus.component > > role="org.apache.maven.shared.filtering.MavenResourcesFiltering" > > * role-hint="ResourceFilter" > > */ > > public class ResourceFilter implements MavenResourcesFiltering { > > ================== > > > > I also added to the main project's POM the maven-resources-plugin > with > > the dependency and maven filtering hints. The problem I am having is > > that Maven cannot find my MavenResourcesFiltering class. Its suppose to > > be able to find it using the role-hint. > > ============= > > <pluginManagement> > > <plugins> > > <plugin> > > <groupId>org.apache.maven.plugins</groupId> > > > <artifactId>maven-resources-plugin</artifactId> > > <version>2.6</version> > > <configuration> > > <dependencies> > > <dependency> > > <groupId>com.xxxx</groupId> > > > > > <artifactId>xxxx-rfp-maven-plugin</artifactId> > > <version>0.2</version> > > </dependency> > > </dependencies> > > <mavenFilteringHints> > > > > > <mavenFilteringHint>ResourceFilter</mavenFilteringHint> > > </mavenFilteringHints> > > </configuration> > > </plugin> > > > > ============= > > > > I suspect the problem is that my plugin's jar is not being loaded to the > > maven-resources-plugin classpath. I suspect this because my jar was not > > being downloaded until I added it to the pom's dependencies list, versus > > it being downloaded when it was just in the maven-resources-plugin > > dependency list. > > > > Am I missing something here? > > > > thanks > > jose > > > > > > On Monday, August 18, 2014 3:08 PM, Jose Martinez > > <[email protected]> wrote: > > > > > > Karl, > > > > Thank you for responding. Yes I can go into more detail. > > Lets go back to my example of the mysql DB credentials. Lets say I have > > five environments. So that means I have 3 variables times 5 > > environments and that comes out to 15 > > various values. From what I understand about the > > maven-resources-plugin that would mean I would have to do one of the > > following: > > 1) Stick those 15 values in the pom and then maybe use 5 different > > profiles, one for each env. This can get quite cumbersome and our > > deployment scripts > would have to call mvn with the correct profile. > > > > 2) Use system variables. Have some code called at some point before > > the maven build that would know which environment it is in and retrieve > > all the values for each known property and make system variables out of > > them. From what I understand this might still require I have them in > > the POM; I'm not sure if maven-resources-plugin would automatically > > replace each ${propertyName} with the proertyName system variable > > without having to have the propertyName in the POM? > > > > > 3) Is there another way that I am missing that this can be done using > > maven-resources-plugin? I can see that it is very powerful tool, as > > everything in Maven has proven to me to be so I'm probably missing > > another approach. > > > > A few things to consider that I would like to have... > > 1) Centralized view into all our properties that can be queried and have > > tools built on top of (e.g. a maven resource filter). > > > > 2) Minimal entries of propertyName. Essentially the ${propertyName} > > should only be entered into the property file and after > that just the > > entries that go into the central data store. The pom is left alone. > > > > 3) Environments can be easily added and removed and altered by only > > touching the centralized datastore. > > > > I guess those three > > things have one thing in common, benefits of having our properties in a > > centralized datastore. At my current employer they built just such a > > system that works off of web services (managed global properties on a > > per environment basis). It is not in production yet so from my point of > > view I will interface out the Dao and just swap implementations when its > > ready... using a simple relational DB at first. > > thanks > > jose > > > > > > On Monday, August 18, 2014 2:06 PM, Karl Heinz Marbaise > > <[email protected]> wrote: > > > > > > > > Hi Jose, > > > > > > can you elaborate a little bit more why you are > not using the > > default > > filtering capabilities of maven-resources-plugin etc. ? > > > > Can you explain what exactly you like to achieve? > > > > > > > >> Hello, > >> > >> We have projects with many property and xml files that need resource > >> filtering per environment. > >> > >> For example in a property file one might see ${mysqlDbHost}, > >> ${mysqlDbPw}, and ${mysqlDbUser}. There would also be a system > >> variable called ENVIRONMENT. Based on the ${propertyName} and > >> ENVIRONMENT value, the resource filter would replace with the correct > >> value. This can be done with a DB (SELECT value FROM properties WHERE > >> env="env" and name="propertyName") or via a web service > >> (getPropertyValue?env=env&name=propertyName). > >> > >> On the Maven side the solution seem to be to create a custom > >> MavenResourcesFiltering. The custom MavenResourcesFiltering > >> implementation would do the lookups I mentioned above for each > >> ${propertyName} encountered in the resource files. > >> > >> 1) Is my assessment that creating a custom MavenResourcesFiltering is > >> the way to go? Maybe this problem is already solved already, since it > >> does not seem unique? > >> > >> 2) I have visited multiple Maven articles on this but still have no > >> idea how to implement it, the sites I visited are listed below. Does > >> anyone know of any document or can provide feedback on how to implement > >> a custom MavenResourcesFiltering? > >> > >> It seems to me that at some point I would need a method that has either > >> gets a list of all the ${propertyName}'s found in a > > file and the ability to provide the value for that property name. > > Following the links I found I cannot tell where that method should be > > implemented and how to get it called from MyMojo.execute(). > >> > >> 1: http://maven.apache.org/shared/maven-filtering/ > >> 2: http://maven.apache.org/shared/maven-filtering/usage.html > >> 3: > >> http://maven.apache.org/guides/plugin/guide-java-plugin-development.html > >> > >> Thank you! > >> jose > >> > > > > Kind regards > > Karl-Heinz Marbaise > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected]
