How do I add user interface elements to my Nexus plugin?

Example Plugins Using UI

The source code of nexus-oss is the best source of current techniques. uSe the branch relevant for your version of Nexus.

We have an issue to create a bare-bones example plugin adding basic user interface elements. See NEXUS-6434. Contributions accepted.

Upgrading Plugin UI from Nexus 2.7.x to Nexus 2.8.x+

The Atlas Plugin should be a good example of a modern plugin.

Make an implementation:

https://github.com/sonatype/nexus-oss/blob/nexus-2.9.x/plugins/internal/nexus-atlas-plugin/src/main/java/org/sonatype/nexus/atlas/internal/UiContributorImpl.java#L21-21

Then add resources in a pattern similar to:

https://github.com/sonatype/nexus-oss/blob/nexus-2.9.x/plugins/internal/nexus-atlas-plugin/src/main/resources/static/js/nexus-atlas-plugin-boot.js

See:

https://github.com/sonatype/nexus-oss/blob/nexus-2.9.x/plugins/basic/nexus-ui-extjs3-plugin/src/main/java/org/sonatype/nexus/plugins/ui/contribution/UiContributionBuilder.java#L117-117

An example changeset of converting a Nexus 2.7.x plugin to support Nexus 2.8 and 2.9 is here:

http://git.eclipse.org/c/tycho/org.eclipse.tycho.nexus.git/commit/?id=ee45d8b04f1c08aebf69b000f32bb9a2a146e33b

What about Nexus Future (3.x)?

The UI has changed dramatically in NX 3.0 and we will write examples and docs on how to build UI plugins for NX 3.0 near it's release date.

 

Have more questions? Submit a request

4 Comments

  • 0
    Avatar
    David Hladky

    I tried to follow the 2.8 path. Unfortunately I am not able to find any way how to add the resources to index.html page. The files are accessible by their url (e.g. http://localhost:8081/nexus/static/js/nexus-gtm-plugin-boot.js), but the Javascript is never called. The Tycho plugin has it the same way and also does not call its js file.

    I thought I will see something like

    bootModules.push('nexus-capabilities-plugin-boot');
    deps.push('css!static/css/nexus-atlas-plugin-all.css?v=2.9.0-04');
    deps.push('static/js/nexus-atlas-plugin-all.js?v=2.9.0-04');

    In the source code, but it is not there. I suppose I need to somehow tell Nexus to make the plugin "required" but I was not able to find a way how to do it. Any thoughts? Thank you for your response.

  • 0
    Avatar
    Peter Lynch

    David,

    First make sure your plugin is loading properly using the plugin console or nexus.log.

    It also important to have your pom.xml setup correctly with nexus plugin bundle plugin execution.

    And of course the contents and name of the js file in the plugin src/main/resources directory should match the artifactid + "-boot".

    If you are still stuck, submit your plugin project to https://support.sonatype.com and we'll try to help.

  • 0
    Avatar
    David Hladky

    I contacted Sonatype support as suggested by Peter and they found the error in my code (the same error has the Tycho unzip plugin). My problem was a dependency in pom.xml:

    <dependency>

              <groupId>org.sonatype.nexus.plugins</groupId>

              <artifactId>nexus-ui-extjs3-plugin</artifactId>

              <scope>provided</scope>

              <type>${nexus-plugin.type}</type>

    </dependency>

    The bold line was missing.

  • 0
    Avatar
    Peter Lynch

    We are closing this article for comments.

    If you have a support license, please contact us by submitting a support ticket.

    If you do not have a support license, please use our Nexus Users List or our other free support resources.

Article is closed for comments.
Powered by Zendesk