As David mentioned you will need to include the "ng build" step in your
build process. I include a portion of the pom where exec-maven-plugin is
used to invoke "npm install" and "ng build".
To expose the angular app we are using HTTP whiteboard. The bundle
activator exports a ResourceMapping service configured with the path of
the ngapp directory. We are doing it in the bundle activator but it could
be done in @Activate of a DS component. In our case, the communication
between the angular side and the server side (a DS component) is done using
web sockets, but I think it would be easy to make a DS component expose a
REST service..
DefaultResourceMapping rootResourceMapping = new DefaultResourceMapping();
rootResourceMapping.setAlias("/myApp");
rootResourceMapping.setPath("/ng");
rootResourceMappingRegistration =
bundleContext.registerService(ResourceMapping.class, rootResourceMapping,
null);
// Redirect 404 errors to the default page
DefaultErrorPageMapping errorpageMapping = new DefaultErrorPageMapping();
errorpageMapping.setError("404");
errorpageMapping.setLocation("/myApp/index.html");
errorpage404Registration =
bundleContext.registerService(ErrorPageMapping.class, errorpageMapping,
null);
// Registers a filter to rewrite the URL "myApp/" to
// index.html
RedirectMatchFilter filter = new RedirectMatchFilter("/myApp/",
"/myApp/index.html");
props = new Hashtable<>();
props.put(ExtenderConstants.PROPERTY_URL_PATTERNS, "/myApp/*");
filtrerRegistration = bundleContext.registerService(Filter.class, filter,
props);
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>exec-npm-install</id>
<phase>generate-sources</phase>
<configuration>
<skip>${maven.exec.skip}</skip>
<workingDirectory>${project.basedir}/src/main/ngapp</workingDirectory>
<executable>${npm.executable}</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
<execution>
<id>exec-npm-ng-build</id>
<phase>generate-sources</phase>
<configuration>
<skip>${maven.exec.skip}</skip>
<workingDirectory>${project.basedir}/src/main/ngapp</workingDirectory>
<executable>${ng.executable}</executable>
<arguments>
<argument>build</argument>
<argument>--target=${build.target}</argument>
<argument>--base-href=/myApp/</argument>
<argument>--no-progress</argument>
<argument>--output-hashing=all</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
João Assunção
Email: [email protected]
Mobile: +351 916968984
Phone: +351 211933149
Web: www.exploitsys.com
On Fri, Aug 3, 2018 at 11:42 PM, David Leangen via osgi-dev <
[email protected]> wrote:
>
> Hi,
>
> Angular 2+ works very differently from AngularJS. In enRoute (or at least
> in v2, I am not yet familiar with the current enRoute), it used AngularJS.
> You used to be able to just include the JS file, and that was it. Angular
> 2+ requires you to build/compile your application first, so you cannot just
> ship the source code (unless you include some kind of interpreter, but I’ve
> never attempted that).
>
> What we do is build the files at some point during the build process, and
> ship the entire dist directory.
>
> It works for us as a deployment mechanism. Never tried it as a DS
> component, though. Because of the way an Angular 2+ app works, I don’t
> immediately see how you could do that. If you figure it out, I’d be
> interested in hearing your solution.
>
>
> Cheers,
> =David
>
>
> On Aug 4, 2018, at 4:55, Matthews, Kevin via osgi-dev <
> [email protected]> wrote:
>
> Hello,
>
> Has anyone integrated the new angular 2+/6 into the enroute project as a
> separate UI module/DS component? I have added the contents of my angular
> src folder into the static folder of the enroute sample but doesn’t seem
> to render the static pages. Should I add the entire angular folder to
> static folder or just the src folder of my angular generate project?
>
> *Kevin Matthews *
> Senior Application Analyst
> First Data, 3975 NW 120 Ave, Coral Springs, FL 33065
> Office: 954-845-4222 *|* Mobile: 561-465-6694
>
> [email protected] *|* firstdata.com
>
> The information in this message may be proprietary and/or confidential,
> and protected from disclosure. If the reader of this message is not the
> intended recipient, or an employee or agent responsible for delivering this
> message to the intended recipient, you are hereby notified that any
> dissemination, distribution or copying of this communication is strictly
> prohibited. If you have received this communication in error, please notify
> First Data immediately by replying to this message and deleting it from
> your computer.
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev