mingness / processing-library-template

GNU General Public License v2.0
0 stars 1 forks source link

how best to synchronize library version #13

Closed mingness closed 2 weeks ago

mingness commented 1 month ago

the library needs to report it's version, so the version needs to be in the java code, but it is also a part of the gradle build parameters. How best to synchronized these values - to manually update is prone to human error.

  1. Check if the gradle build requires the version
  2. if so, check if there is a way to read in gradle properties into java, or java variables into gradle.
mingness commented 1 month ago

I checked where the version parameter in Gradle was used. It's main use is when publishing to Maven, which we don't do at the moment. Otherwise, it's used in the of the javadocs, so it's lack is not obvious for our uses. </p> <p>So it's really at the moment about synchronizing the version in the code, and in the library.properties file. Maybe, we can read in the version from a gradle properties file?</p> <p>Just to be complete, I found another pattern was to store the version in a separate text file, and read it into either Java and gradle. I don't love this.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/mingness"><img src="https://avatars.githubusercontent.com/u/5671413?v=4" />mingness</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>@enkatsu Hmm, it just occurred to me, that if we design the library to use a java function that reads the version from a text file, then that text file would have to be there for the function to run. Looks like the libraries.properties file is copied into the library folder, but it does make the jar brittle, to be dependent on the presence of that file. I guess then, the better option is to see if we can get the value in the Java file into the library.properties file, probably through Gradle?</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/enkatsu"><img src="https://avatars.githubusercontent.com/u/7820411?v=4" />enkatsu</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>@mingness After hearing your opinion, I've come to the same conclusion. In this case, we need to ensure that a class containing the library version information definitely exists. If we want to maintain flexibility in library development, I think it might be a good idea to prepare a separate class like <code>LibraryProperty.java</code> or <code>Version.java</code>.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/mingness"><img src="https://avatars.githubusercontent.com/u/5671413?v=4" />mingness</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>@enkatsu Can you describe more your vision for the Version.java class? thanks.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/enkatsu"><img src="https://avatars.githubusercontent.com/u/7820411?v=4" />enkatsu</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>@mingness When Gradle retrieves the version from Java code, I think there needs to be a fixed class that holds the VERSION variable. However, libraries don't necessarily always have a single main class. A good example of a library composed of multiple classes with similar treatment might be <a href="https://github.com/runemadsen/HTTP-Requests-for-Processing/tree/master/src/http/requests">HTTP-Requests-for-Processing</a>. In this case, I think GetRequest.java and PostRequest.java are treated equivalently. Therefore, when using this template, we might need to establish a convention that there exists a class for managing meta-information such as the library version.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/mingness"><img src="https://avatars.githubusercontent.com/u/5671413?v=4" />mingness</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>@enkatsu I see your reasoning. So the question is, is having a version class in java more intuitive than the string-search-and-replace-via-Gradle method currently employed in the processing template. I think the version class is worth a quick test of what it could look like and how it would integrate in both ways of structuring a library, with a single main class, or the multiple classes.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/enkatsu"><img src="https://avatars.githubusercontent.com/u/7820411?v=4" />enkatsu</a> commented <strong> 1 month ago</strong> </div> <div class="markdown-body"> <p>@mingness Thank you for understanding. I also think it's worth testing. I was able to read the version from compiled Java code using a Gradle script like the one below. I hope this helps 🙏 </p> <pre><code class="language-kts">buildscript { dependencies { classpath(files("release/mylibrary/library/mylibrary.jar")) } } tasks.register("writeVersionTest") { println(com.example.mylibrary.Version.VERSION) }</code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/mingness"><img src="https://avatars.githubusercontent.com/u/5671413?v=4" />mingness</a> commented <strong> 2 weeks ago</strong> </div> <div class="markdown-body"> <p>So, I'm wondering, how necessary it is to return the version from the java application. The contributions manager returns what version is installed, and this is taken from the library.properties file. The processing/processing-library-template, which was built with ant, did configure the application to return the version, which gives the impression that this is necessary. Yet, who uses it? I looked through the github wiki about contributing libraries, and saw no mention of the requirement to return the version from the library itself. So, I might have been mistaken about this task. @Stefterv @SableRaf can I remove this issue, and remove mention of the version from the java code itself? I have seen already, a more recent library that didn't return the version, which is listed in the contributions. Thanks @enkatsu for thinking about this issue.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Stefterv"><img src="https://avatars.githubusercontent.com/u/4988953?v=4" />Stefterv</a> commented <strong> 2 weeks ago</strong> </div> <div class="markdown-body"> <p>I think it is sometimes used to check if you have the right version of a library installed by e.g. <code>println(Library.VERSION);</code> I think for the target audience that this template is aimed at, I would not call it top priority. </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Stefterv"><img src="https://avatars.githubusercontent.com/u/4988953?v=4" />Stefterv</a> commented <strong> 2 weeks ago</strong> </div> <div class="markdown-body"> <p>Especially looking at previous implementations of how this was done before, I don't like the coupling and complexity for a function that is rarely used</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/mingness"><img src="https://avatars.githubusercontent.com/u/5671413?v=4" />mingness</a> commented <strong> 2 weeks ago</strong> </div> <div class="markdown-body"> <p>Thanks for your feedback.</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>