ng build has no permission - amazon-web-services

I am autoconfiguring the CodeBuild for my Spring boot + Angular 4 project, where i use maven-frontend-plugin to install node , npm. Since it installs them locally my ng build is throwing an error like below. Any help?
[INFO] > ng build --prod --no-aot --base-href --allow-root
[ERROR] sh: 1: ng: Permission denied
here is my pom part
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>${project.basedir}/src/main/resources/ui/</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v9.0.0</nodeVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install -g</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script prod</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>

This is why committing the node_modules folder to a repo can be a bad idea. You pulled it, permissions and all. Just wipe out the folder and reinstall, or update the permissions recursively to the folder.

Looks like your current user does not have the permission to run ng.
Try:sudo ng build
Or run which ng to get the path of angular-cli and use chmod to get permission for your current user.

Related

JaCoCo check goal for integration tests

My belief is that JaCoCo Maven plugins check goal does not support integration tests in a multi module project (where the integration tests are in a different module to the code under test).
I have a project with the following structure:
service
├── webapp
├── lib1
├── lib2
└── integration-test
webapp depends on lib1 and lib2 and builds to a WAR, integration-test uses an in memory container to run webapp and execute tests against it.
My configuration is such that JaCoCo is successfully generating consolidated data files (jacoco.exec and jacoco-it.exec in service/target/) for unit tests in {webapp, lib1, lib2} AND integration test coverage for the tests run in integration-test.
When adding in the configuration for check I get this output from the plugin.
[INFO] --- jacoco-maven-plugin:0.7.8:check (default-check) # integration-test ---
[INFO] Skipping JaCoCo execution due to missing classes directory:/home/mark/workspace/service/integration-test/target/classes
The error is accurate, as the integration-test module has only test source, so there is no target/classes directory. Adding a source directory didn't help, check failed indicating 0% coverage because there was no applicable class files in the target/classes directory.
From this (and looking at the check Mojo source) it seems the check goal requires the classes directories of all the modules that it is instrumenting (webapp, lib1, lib2).
No such configuration exists in check that allows me to specify where the classes directories nor does it looks like it supports such a feature looking at the source.
Root / parent pom.xml
<properties>
<sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
</properties>
<-- Note, I am using build/plugins/plugin - not build/pluginManagement/plugin
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<executions>
<execution>
<id>agent-for-ut</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<destFile>${sonar.jacoco.reportPath}</destFile>
</configuration>
</execution>
<execution>
<id>agent-for-it</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<append>true</append>
<destFile>${sonar.jacoco.itReportPath}</destFile>
</configuration>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<phase>verify</phase>
<configuration>
<dataFile>${sonar.jacoco.itReportPath}</dataFile>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.9800</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
integration-test pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<skipTests>${skipTests}</skipTests>
<argLine>${argLine} -Duser.timezone=UTC -Xms256m -Xmx256m</argLine>
<reuseForks>false</reuseForks>
</configuration>
</execution>
</executions>
</plugin>

gwt-maven-plugin does load the "main" log4j configuration instead of the "test" one

On my maven project, I have a different log4j configuration for development and integration environment and also different ones for test purposes than for the main usage of my webapp. Located in :
src/main/resources/dev/log4j.properties
src/main/resources/int/log4j.properties
src/test/resources/dev/log4j_test.properties
src/test/resources/int/log4j_test.properties
So I have different profiles (DEV / INT) to manage thoses differences...
And for surefire (used for unit testing) and failsafe (used for integration testing) plugin I added some configuration :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<log4j.configuration>file:${basedir}/${profile.test.resource}/log4j_test.properties</log4j.configuration>
</systemPropertyVariables>
<!-- Stop the integration tests after the first failure to keep in database
the content of the failed test. -->
<skipAfterFailureCount>1</skipAfterFailureCount>
<includes>
<!-- Include only integration tests -->
<include>**/*IntegrationTest.java</include>
</includes>
<skip>${skip.integration.tests}</skip>
</configuration>
</plugin>
But now I'm adding gwt-maven-plugin for GWT specific unit testing in DEV mode.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>Appication.html</runTarget>
<webappDirectory>${webappDirectory}</webappDirectory>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundles>
...
</i18nMessagesBundles>
<extraJvmArgs>${gwt.extra.args}</extraJvmArgs>
<style>${compile.style}</style>
<module>${module.name}</module>
</configuration>
</plugin>
Is it possible to configure it to point on a specific / filtered lop4j as I did for surefire and failsafe ?*
Thanks,
You can pass system properties in extraJvmArgs

Jacoco Show Source Code

I have some code which reads the exec file and creates html pages for all of my projects running on a webspehre server. The server is on a remote machine, I have all the source code running on the remote machine copied to my local machine. I need to know how, with the html file generated and the exec file how I can view the source code.
Is this even possible?
To successfully create coverage reports with Jacoco from Maven you should add the jacoco maven plugin to your POM.
As explained on the Jacoco Maven Plugin page you need to add the plugin (with the latest version as of this posting):
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6-SNAPSHOT</version>
</plugin>
And then you need to add extra configuration to tell jacoco what phase to instrument tests and then when to generate the reports
This configuration was taken from one of the example jacoco poms for a JAR project that runs JUnit tests under code coverage and creates a coverage report (target/site/jacoco/index.html).
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6-SNAPSHOT</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<!-- implementation is needed only for Maven 2 -->
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<!-- implementation is needed only for Maven 2 -->
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>

How to deploy WAR on JBoss-5.1.0.GA using cargo-maven plugin and wait till it gets deployed before running Integration Tests?

I have a maven web application(Spring+ApacheCXF webservices) and have a couple of IntegrationTests(*IT.java). I want to run integration tests using failsafe plugin by deploying the war file using cargo-maven plugin.
Here is my pom configuration:
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<container>
<containerId>jboss51x</containerId>
<home>C:/jboss-5.1.0.GA</home>
<append>false</append>
<log>${project.build.directory}/logs/jboss51x.log</log>
<output>${project.build.directory}/logs/jboss51x.out</output>
<timeout>300000</timeout>
</container>
<configuration>
<type>existing</type>
<home>C:/jboss-5.1.0.GA/server/default</home>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.jboss.configuration>default</cargo.jboss.configuration>
<cargo.rmi.port>1099</cargo.rmi.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>admin-services</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deployer-deploy</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>deployer-undeploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugin>
But the problem is cargo plugin deploys the WAR file and immediately failsafe plugin is trying to execute the IntegrationTests, and by that time application is not deployed so tests are failing.
With the same configuration I am able to run the integration tests in two steps successfully.
1. execute cargo:deployer-deploy
2. execute integration-test
Is there anyway to trigger failsafe plugin only after the application got deployed by cargo plugin?
I think you can use the pingURL parameter to provide an url to verify the deployment is completed: see http://cargo.codehaus.org/Maven2+Plugin+Reference+Guide
Using cargo you dont have to deploy the application, there is also support for: http://cargo.codehaus.org/Functional+testing (but that depends on your tests of course)

Is there a way to run nodeunit tests through maven/ant

I have created some unit tests for my node.js application in nodeunit. I want to be able to run the tests through maven / ant, because I intend to run them through Jenkins. Has anyone had any success doing this?
The Maven exec plugin can be used to run Nodeunit and the appropriate tests.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>nodeunit</executable>
<workingDirectory>./</workingDirectory>
<arguments>
<argument>tests/node/ServerTests.js</argument>
</arguments>
</configuration>
</plugin>