bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm
193 stars 91 forks source link

Grails - separately built plugins not contributing to manifest #257

Closed ProTip closed 4 years ago

ProTip commented 4 years ago

I'm running into an issue with loading separately built plugins into an application. That is to say they are not built with the main application, but loaded in optionally at boot.

In this scenario the asset contents of these plugins are indeed resolved when requests to assets/* are made. However, it seems that the manifests of the plugins are not being combined with the manifest of the main application:

Browsing the code I'm getting the sense that perhaps the manifests are not being merged.. Is this expected? Is there perhaps a way in bootstrap to merge the manifests manually?

ProTip commented 4 years ago

I was able to use something like this in another plugin's initialization:

void doWithApplicationContext() {
        /**
         * Locate all asset manifest files and load them in
         */
        def manifest = AssetPipelineConfigHolder.manifest
        def manifests = grailsApplication.getParentContext().getResources('classpath*:assets/manifest.properties')

        manifests.each {
            if (it.exists()) {
                log.debug("Loading asset manifest from ${it}")
                def is = it.inputStream
                try {
                    manifest.load(is)
                } finally {
                    is.close()
                }
            }
        }
    }

Adding something like this in the asset pipeline plugin may allow it to work with jar plugins that provide assets but were not built with the main app as well?

davydotcom commented 4 years ago

theres documentation on how to do this with pluginPackage. you dont want to compile them in advance. Optionally there is now a way to register an isolated classloader to a prefix path underneath assets which can resolve an independent manifest.properties

ProTip commented 4 years ago

@davydotcom I don't believe pluginPackage addresses the use case of separately built plugins that are then combined and loaded(not built) with the main application? In this case I very much want the assets compiled in advanced, not during runtime, and for the main application to load the plugins manifest files so the hashed assets can be resolved..