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

LPS-115484 Token definition registry #91176

Conversation

liferay-continuous-integration
Copy link
Collaborator

Forwarded from: liferay-frontend#101 (Took 1 ci:forward attempt in 1 hour 28 minutes)

@izaera
@liferay-frontend

Original pull request comment:
Resend of #91149


This is the -hopefully- final PR for the first version of token definitions API.

It simply provides a singleton OSGi service that retrieves the content of a specific file inside theme bundles. In the future we may evolve the API, but for now this is a good starting point.

See originating PR with the whole discussion on this here.

I have tested this API by manually deploying a modified version of the classic-theme project.

How to use the API

To obtain the token definition of a given theme you just need to inject a ThemeTokenDefinitions instance in your component:

@Component
public class YourComponent {

  @Reference
  protected ThemeTokenDefinitions themeTokenDefinitions;

}

and call its only method passing the theme id:

String aJsonString = themeTokenDefinitions.getTokenDefinitionString(themeId)

How to attach a token definition to a theme:

In your theme's project you just need to add a header to liferay-plugin-package.properties to specify where the JSON file is located inside the WAR:

Token-Definition-Path=WEB-INF/your-wonderful-token-definition.json

You can also omit it and WEB-INF/token-definition.json will be used.

This header will end up in the MANIFEST.MF file of the autogenerated OSGi bundle when your theme is deployed to Liferay.

Then just fill your token-definition.json with whatever is needed (the format is out of the scope of this PR for now, as it hasn't been defined yet).

✔️ ci:test:stable - 20 out of 20 jobs passed

✔️ ci:test:relevant - 46 out of 46 jobs passed in 1 hour 11 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 416a2473fe7d0ecbf40a2ed07d1aba6e290aeda5

Copied in Private Modules Branch:

Branch Name: master-private
Branch GIT ID: 2d61577aa6a76425e17132e68f5aa901f720a686

ci:test:stable - 20 out of 20 jobs PASSED
20 Successful Jobs:
ci:test:relevant - 46 out of 46 jobs PASSED
46 Successful Jobs:
For more details click here.

✔️ ci:test:sf - 1 out of 1 jobs passed in 5 minutes

Click here for more details.

Base Branch:

Branch Name: master
Branch GIT ID: 416a2473fe7d0ecbf40a2ed07d1aba6e290aeda5

Sender Branch:

Branch Name: LPS-115484-new
Branch GIT ID: 7b4fdb596c5866f0a8db97c5138b07b7abf50304

1 out of 1jobs PASSED
1 Successful Jobs:
For more details click here.

Note that themes are WAR files, not OSGi bundles, so people need to add
the Token-Definition-Path header to the
liferay-plugin-package.properties file to make it appear in the
MANIFEST.MF file of the generated OSGi bundle.
It is possible that in the future we have another method returning structured data, so we suffix this one with "String" to leave room for the other method.

See liferay-frontend#87 (comment) .
…ry to avoid ambiguity

We cannot call the service ThemeTokenDefinition because if we model the String in the future with a more complex object we may collide.
@liferay-continuous-integration
Copy link
Collaborator Author

To conserve resources, the PR Tester does not automatically run for forwarded pull requests.

@brianchandotcom
Copy link
Owner

@izaera 1.) can you rename

token-definition.json

to

theme-token-definition.json

2.) Export PluginAutoDeployListenerHelper and instantiate it in ThemeBundleInspector

3.) getTokenDefinition

Can we stick to Theme token definition unless there will be Xyz token definition.

Thanks @izaera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants