Maven copies subfolder xhtml files to main folder - subdirectory

excerpt of my project structure: The WebContent folder contains:
some.xhmtl
| secured
someother.xhtml
When I run Maven clean install from eclipse, the files created in the root folder of target (and in the war) are like that:
-some.xhmtl
-someother.xhtml
| secured
-someother.xhtml
someother.xhtml is duplicated in the ROOT folder.
How can I avoid this?
This is how I have configured the war plugin in pom.xml:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<webXml>path/to/web.xml</webXml>
<webResources>
<resource>
<directory>\WebContent\</directory>
</resource>
<resource>
<directory>\WebContent\secured\</directory>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>

After dealing with Maven war-plugin (basics) another few hours, I found the solution myself:
<resource>
<directory>\WebContent\secured\</directory>
</resource>
This had to be removed. Maven will take the subfolders of
<resource>
<directory>\WebContent\</directory>
</resource>
into the war anyhow. Putting the subfolder as resource just tells Maven to put all files there to the root folder (i.e. "treat subfolder as a main source folder and put all content to the main target folder")

Related

ng build has no permission

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.

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>

Apache CXF - How can I automate WSDL relative path resolution for Client Stubs generation?

In my maven project in order to generating client stubs using apache cxf, I've configured the pom as follows:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<frontEnd>jaxws21</frontEnd>
<markGenerated>true</markGenerated>
<xjcargs>
<xjcarg>-Xts</xjcarg>
</xjcargs>
</defaultOptions>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/MyServiceA_v1.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/MyServiceA_v1.wsdl</wsdlLocation>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/MyServiceB_v1.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/MyServiceB_v1.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Then I've downloaded "manually" all the WSDLs from the server, which exposes the web services, into my resource project folder "\my-project\src\main\resources\wsdl" and all the related XSDs inside my xsd project folder "\my-project\src\main\resources\wsdl\xsd".
After that I've changed manually all the schemaLocation inside the WSDLs file in order to have only relative path (then running cxf generation the java client stubs are correctly generated).
Example:
Inside a wsdl I've changed:
<xs:import namespace="http://ws.myproject.priv.schema/MyServiceA/v1" schemaLocation="http://161.29.123.124:8080/web-1.0/ws/MyServiceA_v1?myServiceA_v1.0.xsd"/>
with the relative path (related to the folder \my-project\src\main\resources\wsdl\xsd)
<xs:import namespace="http://ws.myproject.priv.schema/MyServiceA/v1" schemaLocation="xsd/myServiceA_v1.0.xsd"/>
Is there a way (with maven, apache cxf, ant or something else...) to download automatically all the WSDLs and XSDs from the server to my folders and then automatically changing the server paths with my project relative paths?
How can I automate this process?

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>

Unable to activate bundle in Sling that consumes SOAP service using JAX WS RI

First the requirement:
I need to write code that consumes a SOAP service and build it as an OSGi bundle that can be deployed in Apache Sling. The build is done using Maven 3.0.3
What I have done so far:
I created a maven module and used this for generating SOAP client classes: https://jax-ws-commons.java.net/jaxws-maven-plugin/usage.html. I had to remove the plugin dependency jaxws-tools version 2.2.5 as it was not supporting the -encoding parameter to wsimport. Removing it automatically downloads version 2.2.8 and it works fine as it is a dependency for the POM.
Next, I changed the package type to bundle and included maven-bundle-plugin and maven-scr-plugin to package the generated code as a OSGi bundle and built it using Maven
Finally I deployed it to Sling running locally as a standalone application.
Following are the issues I faced in the given order:
javax.jws package unresolved - I included this as a private-package under configurations for the maven-bundle-plugin
Similar packages that were unresolved were added which includes:
javax.xml.ws
javax.xml.ws.handler
javax.xml.ws.spi
javax.xml.ws.spi.http
javax.xml.ws.wsaddressing
After adding these to the private-package, I started getting this error:
(javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found) javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
Root Cause: java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl not found by org.apache.felix.http.jetty
This is where I hit a roadblock which I am not able to move past.
What I have tried so far to fix this based on numerous answers on google
tried to include this line in the sling.properties file:
sling.bootdelegation.com.sun=com.sun.*
Tried adding this line
sling.system.packages.simple=com.sun.xml.internal.ws.spi.ProviderImpl
Tried adding this line
sling.bootdelegation.class.com.sun.xml.internal.ws.spi.ProviderImpl=com.sun.xml.internal.ws.spi
Tried adding all the packages mentioned earlier to the org.osgi.framework.system.packages property as well as to the jre-1.6 property
After doing this, I can see that these packages are now being exposed by the system bundle. But only the javax.jws is showing as resolved. All other bundles still show as unresolved.
Tried all possible combinations of export-packages.
Even tried to remove unresolved packages as suggested by some posts
I am using Maven 3.0.3, JDK 1.6.0_43, Apache Sling org.apache.sling.launchpad.base.jar 2.4.0 all of which is running on my Mac Book Pro with OSX 10.8.5
Here is my POM snippet that is relevant to this question. If more information is needed I can provide the same as well
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Private-Package>
<!--javax.jws,-->
javax.xml.ws,
javax.xml.ws.handler,
javax.xml.ws.spi,
javax.xml.ws.spi.http,
javax.xml.ws.wsaddressing
</Private-Package>
<!--
<Export-Package>
com.sun.xml.internal.ws.spi
</Export-Package>
<Import-Package>
!javax.xml.ws,*
</Import-Package>
-->
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The name of your generated source package -->
<packageName>com.mycompany.mypackage</packageName>
<wsdlUrls>
<wsdlUrl>http://localhost/mysoapservice?WSDL</wsdlUrl>
</wsdlUrls>
<extension>true</extension>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7</version>
<type>jar</type>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.9</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any help would be greatly appreciated. Waiting for a response in anticipation.