You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by GitBox <gi...@apache.org> on 2020/05/05 06:03:41 UTC

[GitHub] [cayenne] faizel opened a new pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

faizel opened a new pull request #421:
URL: https://github.com/apache/cayenne/pull/421


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] faizel commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
faizel commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-625295919


   I will defer to your judgement, but I would like to explain my case. I see that I can set the property externally when invoking maven, but I don't seem to be able to set the property from within the pom.xml to supply to cgen. I agree that the cayenne runtime probably should not be messing with system properties, however I thought making the change in the maven plugin would be okay as it is part of the build toolchain, not the runtime. When I made the change, I tried to follow what was already done for the cgen-modeler-maven-plugin project (CayenneModelerMojo). In any case, if you think it's not a good idea, that's also fine by me--I can live with having to specify the argument on the command line if needed. Thanks!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] stariy95 commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
stariy95 commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-625390190


   @faizel I think using an explicit option for that will be a good way to go. Ideally, that option should be used directly by the `ClassGenerationAction` in addition to the `"org.apache.velocity.tools"` property.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] faizel commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
faizel commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-625336926


   @stariy95 @andrus The specific use case I was trying to address was for supplying a custom velocity tool to be made available to cgen. This requires the presence of the `org.apache.velocity.tools` system property with a value set to the path of a configuration file describing any additional tools (can be a class path or file system path)
   
   The`CayenneGenerationAction` class will check for the existence of this property before creating the velocity context. At the moment (and I may be wrong about this), the only way to specify this property is via the command line when invoking maven; it is not configurable from within the `pom.xml` file, at least not that I’ve been able to figure out.
   
   If the concern is to prevent opening up the ability to arbitrarily set system properties, then perhaps we can specify the value of that property explicitly as a cgen configuration parameter (e.g. `additionalToolConfig`) and have the plugin set only the required velocity property. That way it doesn’t open up the possibility of setting arbitrary properties. 
   
   In any case, I can live with the inconvenience of specifying the command line switch if needed. It would just be nice to be able to set it in the plugin’s configuration. :)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] andrus commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
andrus commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-625306655


   @faizel - I may have missed the rest of the discussion on the mailing list. What information is passed in the properties and who is consuming them? Perhaps there's another mechanism we can use.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] faizel commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
faizel commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-625424437


   @stariy95 Okay, that sounds good. Let me rework my change as you suggested and check it back in.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] stariy95 commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
stariy95 commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-625208778


   Hi @faizel! Not sure that Cayenne should mess with system properties. It looks like maven can deal with additional properties on its own. I've checked that `mvn cayenne:cgen -Dmyproperty=value` passes value correctly to the Cayenne cgen.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] faizel commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
faizel commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-625968759


   @stariy95 I am able to provide an explicit option for specifying an external tool via `CgenConfiguration`, however in order to make it usable in 'ClassGenerationAction' without using any system properties, I have to defer the creation of the velocity context until it is needed because the needed configuration option is not available to `ClassGenerationAction` in time. It is needed in the constructor, however the configuration is not supplied until after the constructor is invoked (in `DefaultClassGenerationActionFactory`). This means I have to delay the velocity context creation in `ClassGenerationAction` until the `resetContextForArtifact(Artifact)` method is called. It works, but it obviously introduces a risk.
   
   There are a couple of alternatives to this approach, but both have trade offs:
   
   1. Add `CgenConfiguration` as a parameter to `ClassGenerationAction`’s constructor and alter the `DefaultClassGenerationActionFactory` to supply the configuration during construction. That would allow the velocity context to be created where it currently is, in `ClassGenerationAction`’s constructor. This results in an API change for `ClassGenerationAction`'s constructor, however the constructor is only called from the `DefaultClassGenerationActionFactory` (the `CgenConfiguration` is already passed in to its `createAction` factory method as an argument). It would be a simple change to instantiate the action with the cgen configuration as argument rather than setting it immediately afterwards. Regardless, this may not be a desirable approach due to API change.
   
   2. The other alternative is to leave all the code in `ClassGenerationAction` unchanged, and instead explicitly set **only** the `org.apache.velocity.tools` system property in the maven plugin if the `externalToolConfig` configuration is set. Obviously, this means that it would have to set a system property, however the upside is that it is limited in scope to the maven plugin and only one specific system property is set. The existing cgen code is unchanged (with the exception of CgenConfiguration of course).
   
   I would appreciate your thoughts on this as I don’t want to commit something that goes against your vision for Cayenne. My personal preference is for alternative 2, however I understand that is an approach you were trying to avoid. After that, I would prefer the scheme of lazily creating the context.  If none of the three options is suitable, then I have no problem shelving this and maintaining something locally in my own project.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cayenne] stariy95 commented on pull request #421: Set system properties in pom.xml for maven plugin's cgen goal

Posted by GitBox <gi...@apache.org>.
stariy95 commented on pull request #421:
URL: https://github.com/apache/cayenne/pull/421#issuecomment-626645989


   @faizel I'm ok with the 1st option. API change is totally acceptable at this development stage of the 4.2. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org