Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version.properties write issue when using NetBeans on Windows. #6

Closed
mitm001 opened this issue May 23, 2019 · 11 comments
Closed

version.properties write issue when using NetBeans on Windows. #6

mitm001 opened this issue May 23, 2019 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@mitm001
Copy link

mitm001 commented May 23, 2019

When using Netbeans, the program is installed under Program Files but the projects themselves are under the User directory where they have read/write permissions.

Plain vanilla use of the semver-gradle plugin grabs the root directory of the Netbeans install under Program Files for writing and reading the version.properties file.

This means I had to use

semver {
    properties = "/Users/Name/Documents/NB Project Folder/Project Dir/Project folder/version.properties" // read and save properties in "my.version"
}

to actually write to the project folder itself because the Program Files folder does not have write permissions.

Maybe I need to do something different with this plugin but the standard plugins like "java', "idea" etc. do not require this.

The version.properties file should be by default in the same folder the build.gradle folder is and semver defines should be relative to the project unless the user hard codes the location.

semver {
    properties = "/Project Subfolder/version.properties" // read and save properties in "my.version"
}
@ethauvin ethauvin self-assigned this May 23, 2019
@ethauvin ethauvin added the question Further information is requested label May 23, 2019
@ethauvin
Copy link
Owner

@mitm001 Thanks for the report.

Would this work for you?

semver {
    properties = "$projectDir/version.properties";
}

or mabye:

$projectDir/Project Subfolder/version.properties

If it does, I can probably do that internally as you mentioned, but it is not as straight forward as it sounds. Determining what the user's intention are is tricky.

For example, if someone uses:

semver {
    properties = "/foo/version.properties"
}

Do they mean the drive's root directory (/) or the project's root directory?

I think that it would have to be treated like any other path in Gradle. /foo/version.property is an absolute path, foo/version.properties is a relative (to the project's directory) path.

Right now it works if you try running Gradle from the command line, like the examples show. IDEs call Gradle many different ways, I know it works in Intellij IDEA, never tried it with NetBeans.

@mitm001
Copy link
Author

mitm001 commented May 24, 2019

Either would work fine. First one seems more to the point.

Do they mean the drive's root directory (/) or the project's root directory?

I like this myself,

semver {
    properties = "./foo/version.properties"
}

with the period [ ./ ] to dictate current project folder. This is how gradle works.

The default use now works for me without having to use semver for some reason but that exposed another problem when using an IDE.

I should probably note that in another issue.

@mitm001
Copy link
Author

mitm001 commented May 24, 2019

Now that the plugin started working for me when using the Netbeans IDE and defaults, it revealed another problem when there are more than one project using the plugin.

The current default behavior will use the IDE root in windows 7 Program Files folder. So that is Program Files\NetBeans\ when writing the version.properties. When you use the plugin again with another project, it uses the same folder so it not only uses the same properties file, it will overwrite it as well.

semver will fix that but I still think the plugin should always default to the build.gradle location, or project folder even when using an IDE.

Not sure how best to go about that since expected behavior for an IDE is the project folder for all files created.

At minimum, docs should make people aware of the situation before they get to far along.

@mitm001
Copy link
Author

mitm001 commented May 24, 2019

Should mention, using NetBeans 8. Not sure how any of this would play out in the newer versions. Will be switching to those after 13 is released.

@ethauvin ethauvin changed the title version.properties write when using IDE in windows. version.properties write issue when using NetBeans on Windows. May 24, 2019
@ethauvin ethauvin added the enhancement New feature or request label May 24, 2019
@ethauvin ethauvin reopened this May 24, 2019
@ethauvin ethauvin removed the question Further information is requested label May 24, 2019
@ethauvin
Copy link
Owner

ethauvin commented May 24, 2019

@mitm001 Version 1.0.1 should fix your problem(s), by using:

semver {
    properties = "Project folder/version.properties"
}

The Gradle project directory is now assumed as the default location. Notice that I did not include a / at the start, because under Linux that means the drive's root.

Play with it and let me know if that works for you.

@ethauvin
Copy link
Owner

semver {
    properties = "./foo/version.properties"
}

./foo/version.properties, foo/version.properties and $projectDir/foo/version.properties are treated the same by Gradle, it's just a question of personal preferences.

My fix should handle any of it. What I've done is checked to see if the provided properties location is an absolute or relative path; if it is relative, the project directory path is added to make it absolute.

@mitm001
Copy link
Author

mitm001 commented May 24, 2019

Getting closer.

Now it does write the properties file to the project folder by default or when using semver but the file is empty.

The file containing the actual properties is in the NetBeans Program Files directory though so there are now two properties files. Including when setting semver.

@ethauvin ethauvin reopened this May 24, 2019
@ethauvin
Copy link
Owner

I think I know why that is, let me work on it.

@ethauvin
Copy link
Owner

@mitm001 Give 1.0.2 a try, I think that should take care of it.

I've added some tests that emulate your situation, so it shouldn't happen again.

@mitm001
Copy link
Author

mitm001 commented May 24, 2019

Perfect. Very nice. Defaults to project folder, semver works great.

Now the properties file actually works as a properties file where before it was plain text when opened.

Thank you.

@mitm001
Copy link
Author

mitm001 commented May 24, 2019

Now the properties file actually works as a properties file where before it was plain text when opened.

Seems that wasn't due to anything but netbeans where double click opens the file as text rather than a properties file. Using Open command opens it as a properties file.

Thanks again.

ethauvin added a commit that referenced this issue Jul 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants