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

Provide defaults, especially for version info. #98

Closed
garretwilson opened this issue Dec 17, 2018 · 3 comments · Fixed by #205
Closed

Provide defaults, especially for version info. #98

garretwilson opened this issue Dec 17, 2018 · 3 comments · Fixed by #205

Comments

@garretwilson
Copy link

garretwilson commented Dec 17, 2018

After several years of intending to try Launch4j, I've finally got around to testing it with your Maven plugin. I've just got things working, and your Maven plugin so far seems to make the process really snazzy.

In the spirit of Maven (and many of its plugins), which provides reasonable defaults for many properties, I'd like to propose that you provide reasonable defaults. For example for <errTitle> you could default to

<errTitle>${project.name}</errTitle>

But most importantly defaults for <versionInfo> would really help. After a bit of experimentation, let me suggest the following. (You may be able to improve upon these.)

<versionInfo>
  <fileVersion>${project.baseVersion}.0</fileVersion>
  <txtFileVersion>${project.version}</txtFileVersion>
  <fileDescription>${project.description}</fileDescription>
  <copyright>Copyright © ${project.inceptionYear}-${build.year} ${project.organization.name}. All rights reserved.</copyright>
  <productName>${project.name}</productName>
  <internalName>${project.artifactId}</internalName>
  <productVersion>${project.baseVersion}.0</productVersion>
  <txtProductVersion>${project.version}</txtProductVersion>
</versionInfo>

Versions

Note that Launch4j seems to require a version in the format x.x.x.x, so we can't just use ${project.version} (although we can use that for the text variations). So we have to take the base Maven project version and add an .0 to it. One can get the base version number using the following. (I'm sure your plugin can determine the whole thing programmatically internally without the need for an extra plugin.)

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>3.0.0</version>
  <executions>
    <execution>
      <id>set-project-base-version</id>
      <goals>
        <goal>regex-property</goal>
      </goals>
      <configuration>
        <name>project.baseVersion</name>
        <value>${project.version}</value>
        <regex>-SNAPSHOT</regex>
        <failIfNoMatch>false</failIfNoMatch>
      </configuration>
    </execution>
  </executions>
</plugin>

Note that this will only work if the project version has the format x.x.x with optional -SNAPSHOT. If the project version has fewer or more components, the final number of components won't be correct. But if you set this programmatically in the plugin, then none of this matters; you can ensure the correct number of components when building the default string, and won't even need this extra plugin in the POM.

Copyright

The copyright message was inspired by the Maven Javadoc Plugin, which uses a bottom copyright message of:

Copyright © {inceptionYear}–{currentYear} {organizationName}. All rights reserved.

There is no real need to escape the © symbol. Note that the en dash symbol doesn't show up well (at least on Windows 10 in the properties dialog details tab), so I (sadly) switched to using a normal dash - symbol. I also had to update the other properties to use the latest Maven convention. And lastly in order to get ${build.year} you'll need to set that property. You can do this with a separate plugin, but again, this is something you can undoubtedly do programmatically within your own plugin.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>3.0.0</version>
  <executions>
    <execution>
      <id>set-build-year</id>
      <goals>
        <goal>timestamp-property</goal>
      </goals>
      <configuration>
        <locale>en</locale>
        <name>build.year</name>
        <pattern>yyyy</pattern>
      </configuration>
    </execution>
  </executions>
</plugin>

Original Filename

For the <originalFilename>, you should just use the last path segment of the <outfile> configuration as the default value. Because after all, since that is the name of the file you are generating, that could reasonably be said to be the original filename. 😄

@lukaszlenart
Copy link
Collaborator

I'm not a fan of defaults, magic doesn't help. Anyway I would suggest preparing a PR with your ideas, then we can discuss further.

Also please notice that x.x.x.x version format was used before introducing a Semantic Versioning and it's still very popular.

@garretwilson
Copy link
Author

I'm not a fan of defaults, magic doesn't help.

There's no magic in saying that the description of the generated .exe just might match the description of your project, for example.

Also please notice that x.x.x.x version format was used before introducing a Semantic Versioning and it's still very popular.

Wonderful. They can both be popular. That doesn't change that fact that in Maven the appropriate format of a non-release version is x.x.x.x.x.x (however many xs you want) with a -SNAPSHOT on the end, and I was providing one option for removing that so that it would at least work.

But forget the version manipulation if you don't like it and/or don't think it's appropriate. I provided a lot of options for you to choose from. Are you such an enemy of defaults that you think defaulting the product name to match the project name is helping the user too much? (Yes, I know that sometimes the "project" is different than the "product", but the point of a default is to give a value that works for most people and still allows the outliers to use the value they want, which they would have had to do anyway without the default.)

People just wanting to generate an .exe will often be bewildered with the number of required options, and it take quite a bit of research just to figure out what they mean; this is a significant hurdle in "just getting it to spit out an .exe".

Anyway I would suggest preparing a PR with your ideas, then we can discuss further.

Unfortunately I'm extremely busy and won't have time to submit a pull request. I already invested a significant amount of time in presenting and describing the options in an understandable way. I was hoping to help your project and other users of your project. I've already integrated these defaults into our POMs. If you don't find it useful, feel free not to use it.

Good luck,

Garret

@garretwilson
Copy link
Author

P.S. And another sincere thanks for publishing this project.

koksyn added a commit to koksyn/launch4j-maven-plugin that referenced this issue Dec 29, 2022
lukaszlenart pushed a commit that referenced this issue Jan 6, 2023
* Fix: Escape angle brackets in Markdown documentation to be printed out.

GitHub uses one of many kinds of Markdown syntaxes. In this one it does not display plain text inside angle brackets (like <any text>) in the headers, so we need to escape them. For details, please see the issue: microsoft/vscode#12491

* `disableVersionInfoDefaults` docs note added

* Snapshot version bump according to default parameters changes

* New parameter for disabling VersionInfo defaults

* Filling out VersionInfo defaults

* Filling out VersionInfo defaults

* Unit tests for Copyright generator

* Copyright generator description

* JUnitParams lib added to POM.xml

* Unit tests for Launch4j fileVersion generator

* Additional Unit tests for Launch4j fileVersion generator

* Refactoring of Launch4j fileVersion generator

* "errTitle" default value provided

* "errTitle" default value in docs

* "versionInfo -> originalFilename" default value added

* release version notes Resolves #98

* Line added to MOJO doc

* trademarks & companyName also filled by defaults

* Mockito Core library added

* VersionInfo refactoring

* VersionInfo unit tests

* Adds missing VersionInfo unit tests

* Adds missing Mojo param to MojoTest

* Refactoring MojoTest

* Missing dependency added to POM

* Possibility of not filling out VersionInfo in XML at all

* Documentation for VersionInfo defaults added

* Throwing exception datailed descriptions

* Release version without snapshot

* Revert "Release version without snapshot"

This reverts commit d019663.

* default scope for filling out defaults inside VersionInfo

* Newline's at the end of the files

* Private constructors for utility classes added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants