Maven ACR Plugin
  1. Maven ACR Plugin
  2. MACR-3

Maven site should has an example with adding Main Class

    Details

    • Type: Improvement Improvement
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      Maven ACR plugin should confirm if the resulting Manifest contain a setting for Main-Class, because The Java EE spec requires that app clients specify the main class (http://www.java.net/forum/topic/glassfish/glassfish/problems-using-java-web-start-application-client-libraries-not-found).

      If Manifest does not contain Main-Class a warning should be emitted.

      Also, It would be worth if there were working examples specifying Main-Class added to the site http://maven.apache.org/plugins/maven-acr-plugin/.

      Presently, users tend to create application clients without Main-Class and may get strange errors while trying to launch the application client. One example of these errors, may be accessed in:
      http://www.java.net/forum/topic/glassfish/glassfish/problems-using-java-web-start-application-client-libraries-not-found

        Activity

        Hide
        Michael Osipov added a comment -

        This issue has been auto closed because it has been inactive for a long period of time. If you think this issue still applies, retest your problem with the most recent version of Maven and the affected component, reopen and post your results.

        Show
        Michael Osipov added a comment - This issue has been auto closed because it has been inactive for a long period of time. If you think this issue still applies, retest your problem with the most recent version of Maven and the affected component, reopen and post your results.
        Hide
        Gustavo Orair added a comment -

        Lundberg,
        notice that the apparently some documentation looks like deplicated.
        However, it is necessary because the section "Make The Jar Executable" called which explains how to specify a Main-Class is targeted just to jar package type. Since, the appclient jar type was created, we need instruct how to specify the Main-Class also to appclient type.
        Maybe, the archiver doc may include a section for appclient modules.

        Show
        Gustavo Orair added a comment - Lundberg, notice that the apparently some documentation looks like deplicated. However, it is necessary because the section "Make The Jar Executable" called which explains how to specify a Main-Class is targeted just to jar package type. Since, the appclient jar type was created, we need instruct how to specify the Main-Class also to appclient type. Maybe, the archiver doc may include a section for appclient modules.
        Hide
        Gustavo Orair added a comment -

        Lundberg,
        As you recommended, I am sending missing pieces to be added in plugin site.

        I would change inside the Usage Page
        (http://maven.apache.org/plugins/maven-acr-plugin/usage.html):

        I would add before "If the packaging type defined in the pom.xml is
        app-client, the package lifecycle phase can be used" the sentence:
        "Define the package type to be app-client."

        Before:
        "Pay attention that prior to Maven 3.0.4, the plugin's extension must
        be enabled since the app-client packaging type is new."

        I would add
        "Pay attention that JEE spec requires to add a manifest and a
        Main-Class. So, your application client need this to be JEE compliant."
        See "How can I specify a Main-Class: entry in the manifest of an
        Application Client jar?" inside FAQ for more details.

        Note: Some application servers may execute an application client without a Main-Class if you specify the Main-Class while running, however specify Main-Class while running would not be possible for some technologies such as Java Web Start Technology.

        Inside FAQ Page (http://maven.apache.org/plugins/maven-acr-plugin/faq.html):
        Add as the FIRST question:
        1 - How can I specify a Main-Class: entry in the manifest of an
        Application Client jar?

        JEE spec and also some launching technologies such as Java Web Start Technology require to add a manifest and a Main-Class in application clients. This requirement is done because the launching technology need to know which method to execute.
        So, you need to configure Maven Archiver accordingly inside the acr-plugin configuration of your pom.xml app-client project.
        Here is a sample pom.xml configured to use the class fully.qualified.MainClass as the main class:

        <project>
        ...
        <build>
        <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-acr-plugin</artifactId>
        ...
        <configuration>
        <archive>
        <manifest>
        <mainClass>fully.qualified.MainClass</mainClass>
        </manifest>
        </archive>
        </configuration>
        ...
        </plugin>
        </plugins>
        </build>
        ...
        </project>

        This configuration is really similar to making the jar executable for jar Maven projects.
        See "Make the jar executable" in Maven Archiver Examples Page for more details
        (http://maven.apache.org/shared/maven-archiver/examples/classpath.html#aMake).

        Optionally you can configure Archiver to use your own manifest file
        with an already define Main-Class. Details can be found here
        http://maven.apache.org/shared/maven-archiver/examples/manifestFile.html.

        Obviously, a good improvement should be make maven acr plugin warns
        the user if do not find a Main Class configuration neither a
        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>.
        In the case user added a manifestFile option and plugin couldn't check
        if this manifestFile has a Main-Class, the plugin could at least info
        the user to add a MainClass inside you own Manifest-File.

        Best regards,

        Show
        Gustavo Orair added a comment - Lundberg, As you recommended, I am sending missing pieces to be added in plugin site. I would change inside the Usage Page ( http://maven.apache.org/plugins/maven-acr-plugin/usage.html): I would add before "If the packaging type defined in the pom.xml is app-client, the package lifecycle phase can be used" the sentence: "Define the package type to be app-client." Before: "Pay attention that prior to Maven 3.0.4, the plugin's extension must be enabled since the app-client packaging type is new." I would add "Pay attention that JEE spec requires to add a manifest and a Main-Class. So, your application client need this to be JEE compliant." See "How can I specify a Main-Class: entry in the manifest of an Application Client jar?" inside FAQ for more details. Note: Some application servers may execute an application client without a Main-Class if you specify the Main-Class while running, however specify Main-Class while running would not be possible for some technologies such as Java Web Start Technology. Inside FAQ Page ( http://maven.apache.org/plugins/maven-acr-plugin/faq.html): Add as the FIRST question: 1 - How can I specify a Main-Class: entry in the manifest of an Application Client jar? JEE spec and also some launching technologies such as Java Web Start Technology require to add a manifest and a Main-Class in application clients. This requirement is done because the launching technology need to know which method to execute. So, you need to configure Maven Archiver accordingly inside the acr-plugin configuration of your pom.xml app-client project. Here is a sample pom.xml configured to use the class fully.qualified.MainClass as the main class: <project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-acr-plugin</artifactId> ... <configuration> <archive> <manifest> <mainClass>fully.qualified.MainClass</mainClass> </manifest> </archive> </configuration> ... </plugin> </plugins> </build> ... </project> This configuration is really similar to making the jar executable for jar Maven projects. See "Make the jar executable" in Maven Archiver Examples Page for more details ( http://maven.apache.org/shared/maven-archiver/examples/classpath.html#aMake ). Optionally you can configure Archiver to use your own manifest file with an already define Main-Class. Details can be found here http://maven.apache.org/shared/maven-archiver/examples/manifestFile.html . Obviously, a good improvement should be make maven acr plugin warns the user if do not find a Main Class configuration neither a <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>. In the case user added a manifestFile option and plugin couldn't check if this manifestFile has a Main-Class, the plugin could at least info the user to add a MainClass inside you own Manifest-File. Best regards,
        Hide
        Dennis Lundberg added a comment -

        Yes, I understood that is what you wanted.

        I am just pointing out that some of it is already documented elsewhere. So those bits will not be documented on the plugin site.

        If you write up the missing pieces I can add them to the plugin site.

        Show
        Dennis Lundberg added a comment - Yes, I understood that is what you wanted. I am just pointing out that some of it is already documented elsewhere. So those bits will not be documented on the plugin site. If you write up the missing pieces I can add them to the plugin site.
        Hide
        Gustavo Orair added a comment -

        When I said Maven site should have an example I really means ACR Plugin site (the ticket was created to Maven ACR Plugin project.

        Show
        Gustavo Orair added a comment - When I said Maven site should have an example I really means ACR Plugin site (the ticket was created to Maven ACR Plugin project.
        Hide
        Dennis Lundberg added a comment -

        After following the link there is a menu option called "Set Up The Classpath" which takes you to http://maven.apache.org/shared/maven-archiver/examples/classpath.html

        On that page there is a section called "Make The Jar Executable" which explains how to specify a Main-Class.

        These docs (at http://maven.apache.org/shared/maven-archiver/) are shared by all archiving plugins, and includes functionality that is common for all of them.

        If there is more specific documentation that applies only to a specific plugin, then it should be located in that plugin. I.e. the suggestion to instruct user to add manifest and Main-Class because the JEE spec requires it, should be in on the ACR Plugin site.

        Show
        Dennis Lundberg added a comment - After following the link there is a menu option called "Set Up The Classpath" which takes you to http://maven.apache.org/shared/maven-archiver/examples/classpath.html On that page there is a section called "Make The Jar Executable" which explains how to specify a Main-Class. These docs (at http://maven.apache.org/shared/maven-archiver/ ) are shared by all archiving plugins, and includes functionality that is common for all of them. If there is more specific documentation that applies only to a specific plugin, then it should be located in that plugin. I.e. the suggestion to instruct user to add manifest and Main-Class because the JEE spec requires it, should be in on the ACR Plugin site.
        Hide
        Gustavo Orair added a comment -

        I already followed this link, but this link does not show a specific manifest to application clients.
        I think the fact that Java EE spec requires that app clients specify the main class should should be considered and at least a simple specific manifest for an application client example that specifies Main-Class should be provided.
        Also, the doc may instruct users to specify manifest and Main-Class stating it is required by Java EE spec.
        This doc would improve user experience reducing risks of problems.

        Show
        Gustavo Orair added a comment - I already followed this link, but this link does not show a specific manifest to application clients. I think the fact that Java EE spec requires that app clients specify the main class should should be considered and at least a simple specific manifest for an application client example that specifies Main-Class should be provided. Also, the doc may instruct users to specify manifest and Main-Class stating it is required by Java EE spec. This doc would improve user experience reducing risks of problems.
        Hide
        Dennis Lundberg added a comment -

        If you follow the link at the bottom of the page you will find examples of how to configure the manifest.

        Show
        Dennis Lundberg added a comment - If you follow the link at the bottom of the page you will find examples of how to configure the manifest.

          People

          • Assignee:
            Unassigned
            Reporter:
            Gustavo Orair
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development