You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/02/29 22:29:57 UTC
[GitHub] [netbeans] errael opened a new pull request #1991: [NETBEANS-3918]
defer creation of target folder until/if needed
errael opened a new pull request #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991
Without this change, there is some directory creation in BasicPanelVisual.store, but that method is called in several situations where directory/DataFolder creation should not occur. This PR moves the creation code to TemplateWizard.getTargetFolder(), which defers the creation until needed. Unfortunately, with a breakpoint, I have not seen getTargetFolder() invoked when creating a maven project.
This PR is designed to preserve semantic; it is highly targeted and relatively simple. There may be better/simpler/more-direct fixes; but I am unfamiliar with the overall architecture; revset which introduced the spurious directory creation:
```
changeset: 301468:76d9cafcee35
branch: ArchetypesUI268677
parent: 299970:0c5aa5cdb86a
user: Jaroslav Tulach <jt...@netbeans.org>
date: Tue Oct 25 21:52:49 2016 +0200
summary: #268677: Recognizing .archetype template files and using them to instantiate projects via mvn archetype
```
This simplest fix would be to simply remove the directory creation from BasicPanelVisual and not put it in getTargetFolder(). This would fix the cases I have seen; in those cases the directory is created by maven project instantiation and the data fold is not referenced. But this would not preserve semantics around TemplateWizard and DataFolder.
This PR also fixes [NETBEANS-3875] which is about failure of maven artifact creation.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] errael commented on issue #1991: [NETBEANS-3918] defer
creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
errael commented on issue #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#issuecomment-593165641
New commit should be close.
In the comment for setTargetFolder(Supplier) I had following, but seemed to much, took it out
```
* If <CODE>TemplateWizard.getTargetFolder()</CODE> is called and
* the target folder is not set then invoke folderCreator
* to create the directory and <CODE>DataFolder</CODE>.
```
Do you know someplace in the regular NetBeans code where I can use this and see it working in a non-test situation?
Did not error check that both version of setTargetFolder are used, or other weird cases. Seemed like overkill.
A little unclear about apichanges "compatibility". Since no differences if don't use new method, assume binary and source compatible. Not sure what modification means.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] jtulach commented on a change in pull request #1991:
[NETBEANS-3918] defer creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
jtulach commented on a change in pull request #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#discussion_r386077821
##########
File path: platform/openide.loaders/src/org/openide/loaders/TemplateWizard.java
##########
@@ -47,6 +48,13 @@
* @see TemplateRegistration
*/
public class TemplateWizard extends WizardDescriptor {
+ /** Set to <CODE>File</CODE> to use for deferred creation of target folder.
+ * If <CODE>TemplateWizard.getTargetFolder()</CODE> is called and the
+ * the target folder has not been set then this property value is
+ * used to create the directory and DataFolder. This allows deferral
+ * of creation of DataFolder until and <em>if</em> it is needed.
+ */
Review comment:
This would be an API change and as such it would need additional attributes of an API change. See the [wiki page](http://wiki.netbeans.org/APIDevelopment) for overall description. Here is the enumeration of what I am missing the most:
- incrementing module version, using `@since` tag
- modifying `apichanges.xml`
- testing the change
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] errael commented on issue #1991: [NETBEANS-3918] defer
creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
errael commented on issue #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#issuecomment-593201834
Some time after seeing the earlier build failure, my subconscious informed me of a minor semantic difference. Previously
`wiz.setTargetFolder(null); wiz.getTargetFolder();`
would throw an assertion. Along with changing method name to setTargetFolderLazy, in setTargetFolder I've added
```
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "set targetFolder=" + f + " for " + this, new Throwable());
}
+ if(f == null) {
+ targetDataFolderCreator = null;
+ }
targetDataFolder = f;
}
```
This maintains semantics AFAICT.
And set java/maven dependency to 7.76
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] jtulach commented on a change in pull request #1991:
[NETBEANS-3918] defer creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
jtulach commented on a change in pull request #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#discussion_r386078392
##########
File path: platform/openide.loaders/src/org/openide/loaders/TemplateWizard.java
##########
@@ -244,7 +252,14 @@ public DataFolder getTemplatesFolder () {
public DataFolder getTargetFolder () throws IOException {
LOG.log(Level.FINE, "targetFolder={0} for {1}", new Object[] {targetDataFolder, this});
if (targetDataFolder == null) {
- throw new IOException(NbBundle.getMessage(TemplateWizard.class, "ERR_NoFilesystem"));
+ // Fix for [NETBEANS-3918] and [NETBEANS-3875]
+ File targetFolderFile = (File) getProperty(PROP_TARGET_FOLDER_HINT);
+ if(targetFolderFile != null) {
+ targetFolderFile.mkdirs();
+ setTargetFolder(DataFolder.findFolder(FileUtil.toFileObject(targetFolderFile)));
Review comment:
Please note that `TemplateWizard` hasn't yet been using `java.io.File`. This would be the first time and I am not happy about it as it limits the usage of `TemplateWizard` to local disk. Could you consider alternative solution? Could you introduce
```java
public void setTargetFolder(Supplier<DataFolder> toBeCreatedFolder) {
}
```
e.g. give the code a chance to work with `DataFolder` and `FileObject` only, but delay creation of the actual folder as much as possible?
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] jtulach commented on issue #1991: [NETBEANS-3918] defer
creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
jtulach commented on issue #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#issuecomment-593193356
Excellent! The last remaining thing: the java/maven module has to depend on 7.76 version of opening.loaders now, otherwise it will not link. Then the change can be merged.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] JaroslavTulach merged pull request #1991:
[NETBEANS-3918] defer creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
JaroslavTulach merged pull request #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] errael commented on issue #1991: [NETBEANS-3918] defer
creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
errael commented on issue #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#issuecomment-593202774
If you're up to it, there's an almost trivial change PR#1980 which would finish up the obvious/glaring problems with maven project creation.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] jtulach commented on a change in pull request #1991:
[NETBEANS-3918] defer creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
jtulach commented on a change in pull request #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#discussion_r386077499
##########
File path: platform/openide.loaders/src/org/openide/loaders/TemplateWizard.java
##########
@@ -244,7 +252,14 @@ public DataFolder getTemplatesFolder () {
public DataFolder getTargetFolder () throws IOException {
LOG.log(Level.FINE, "targetFolder={0} for {1}", new Object[] {targetDataFolder, this});
if (targetDataFolder == null) {
- throw new IOException(NbBundle.getMessage(TemplateWizard.class, "ERR_NoFilesystem"));
+ // Fix for [NETBEANS-3918] and [NETBEANS-3875]
+ File targetFolderFile = (File) getProperty(PROP_TARGET_FOLDER_HINT);
Review comment:
The proposed property `PROP_TARGET_FOLDR_HINT` can hold any value, not just `File`. To prevent `ClassCastException` change this and next line to `if (value instanceof File) { ... }`.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] errael commented on issue #1991: [NETBEANS-3918] defer
creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
errael commented on issue #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#issuecomment-593167685
Travis build fails
```
/home/travis/build/apache/netbeans/ide/projectuiapi/src/org/netbeans/spi/project/ui/templates/support/Templates.java:152: error: reference to setTargetFolder is ambiguous
[repeat] ((TemplateWizard)wizardDescriptor).setTargetFolder( null );
```
Ambiguous reference. To stay compatible, I can change the new method to unique name like
`setLazyTargetFolder(Supplier)`
Comment?
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
[GitHub] [netbeans] errael commented on issue #1991: [NETBEANS-3918] defer
creation of target folder until/if needed
Posted by GitBox <gi...@apache.org>.
errael commented on issue #1991: [NETBEANS-3918] defer creation of target folder until/if needed
URL: https://github.com/apache/netbeans/pull/1991#issuecomment-593171369
Actually, I like
`setTargetFolderLazy(Supplier)`
better. You would see both methods together in code completion.
----------------------------------------------------------------
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
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists