I just integrated PostgreSQL into my first JAX-RS project and now I am wondering how I can setup databases to test my application using Maven. I already managed to create the database and the tables I need before the test phase starts, but I was not able to fill the tables with test data. I am missing a good guide that tells me how to setup my spozz_db_testdata.xml file. I currently just know how I could add rows that only use primitive types like string or integer, but what about binary data?
Any solution or tips will help.
Current spozz_db_testdata.xml
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<avatars />
<users />
<spots />
<spot_revisions />
<spot_images />
<comments />
</dataset>
pom.xml
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.avedo.spozz</groupId>
<artifactId>Spozz-Webservice</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>9.1.0.v20131115</jetty.version>
<jersey.version>1.8</jersey.version>
<junit.version>4.11</junit.version>
<apache.commons.version>1.3.2</apache.commons.version>
<apache.http.version>4.3.2</apache.http.version>
<jsp.version>2.5</jsp.version>
<maven.compiler.plugin.version>2.5.1</maven.compiler.plugin.version>
<sql.maven.plugin.version>1.5</sql.maven.plugin.version>
<postgresql.jdbc.version>9.1-901.jdbc4</postgresql.jdbc.version>
</properties>
<dependencies>
...
<!-- PostgreSQL -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>${sql.maven.plugin.version}</version>
<dependencies>
<!-- Specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
</dependency>
</dependencies>
<!-- Common configuration shared by all executions -->
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432:spozz_db</url>
<username>postgres</username>
<password>root</password>
<!-- You can comment out username/password configurations and have
maven to look them up in your settings.xml using ${settingsKey} -->
<settingsKey>sensibleKey</settingsKey>
<!-- All executions are ignored if -Dmaven.test.skip=true -->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<id>drop-schema-before-test-if-any</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<!-- Need another database to drop the targeted one -->
<url>jdbc:postgresql://localhost:5432:postgres</url>
<autocommit>true</autocommit>
<sqlCommand>DROP SCHEMA spozz CASCADE</sqlCommand>
<!-- Ignore error when database is not available -->
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>src/main/sql/spozz-schema.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<dependencies>
<!-- Specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
</dependency>
</dependencies>
<!-- Common configuration shared by all executions -->
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432:spozz_db</url>
<username>postgres</username>
<password>root</password>
<!-- You can comment out username/password configurations and have maven
to look them up in your settings.xml using ${settingsKey} -->
<settingsKey>sensibleKey</settingsKey>
<!-- All executions are ignored if -Dmaven.test.skip=true -->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>operation</goal>
</goals>
<!-- Specific configurations -->
<configuration>
<type>CLEAN_INSERT</type>
<src>src/test/resources/spozz_db_testdata.xml</src>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
</project>
Related
I am trying to import a dependency from another project. To do so I created a project A and deploy it on JitPack, but when I'm trying to use it as a dependency, Maven downloads the dependency from JitPack, but in the JAR file there is only the META-INF folder, without my class, why?
Here is the POM of the first project that I am trying to use as dependency:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>wsStub</groupId>
<artifactId>wsStub</artifactId>
<version>0.0.5</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<!-- ============ -->
<!-- Opzioni base -->
<!-- ============ -->
<properties>
<wsdl>http://localhost:9080/SoapSd/UniboServices?wsdl</wsdl>
<!-- Opzioni base -->
<ws.stub.package.name>it.unibo.test.services</ws.stub.package.name>
<!-- Specifici -->
<cxf.version>2.5.2</cxf.version>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<pluginManagement>
<plugins>
<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>
<tasks>
<echo>Using WSDL ${wsdl}</echo>
</tasks>
<sourceRoot>target/generated-sources</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${wsdl}</wsdl>
<extraargs>
<extraarg>-verbose</extraarg>
<extraarg>-client</extraarg>
<extraarg>-frontend</extraarg>
<extraarg>jaxws21</extraarg>
<extraarg>-p</extraarg>
<extraarg>${ws.stub.package.name}</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.8</version>
<configuration>
<!-- git commit message -->
<message>Maven artifacts for ${project.version}</message>
<!-- disable webpage processing -->
<noJekyll>true</noJekyll>
<!-- matches distribution management repository url above -->
<outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
<merge>true</merge>
<includes>
<include>**/*</include>
</includes>
<!-- github repo name -->
<repositoryName>wsStub</repositoryName>
<!-- github username -->
<repositoryOwner>Diantha</repositoryOwner>
</configuration>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<distributionManagement>
<repository>
<id>internal</id>
<url>file://${project.build.directory}/mvn-repo</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>${cxf.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
After I use Maven's deploy goal, I also use tag the project.
Problem: I am using allure reporting to generate some reports after running some tests, when I run the tests manually from within eclipse the allure-results directory is successfully created inside the /target/allure-results directory.
However, when I pass in some arguments after calling maven from the command line, with something like this:
call mvn clean
call mvn test -Dbrowser=Chrome -DseleniumEnvironment=local -Dreporttogenerate=censoredconfigsetting -Dcucumber.options="--tags #censoredTag
Note: mvn clean test does generate allure-reports from the command line, why are my arguments breaking this?
This instead, is creating a /cucumber/results/ directory in /target, I am very confused as to why this differs, doesn't seem like these tags should have much problems there, I suspect its possibly my pom.xml causing issues.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.kore</groupId>
<artifactId>kore-automation</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>kore-automation</name>
<properties>
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
<build.number>${maven.build.timestamp}/${platform}/${platformVersion}/${browser}/${browserVersion}</build.number>
<reports.directory>${project.build.directory}/../reports/${build.number}</reports.directory>
<cucumber.tags>~#ignore</cucumber.tags>
<!-- Needed for allure-maven-plugin to specify report version -->
<aspectj.version>1.8.4</aspectj.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.8.0-alpha2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.8.0-alpha2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-junit</artifactId>
<version>2.0.0.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-cucumber-jvm-adaptor</artifactId>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0.1</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>read-properties</id>
<activation>
<file>
<exists>src/test/resources/config.properties</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src\test\resources\config.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>4.1.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generateRunners</goal>
</goals>
<configuration>
<!-- Mandatory -->
<!-- comma separated list of package names to scan for glue code -->
<glue>
<package>webDriver</package>
<package>censored</package>
<package>censored</package>
<package>testRunner</package>
</glue>
<outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
<!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->
<featuresDirectory>src/test/java/</featuresDirectory>
<!-- Directory where the cucumber report files shall be written -->
<!-- cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir-->
<!-- comma separated list of output formats json,html,rerun.txt -->
<!-- format>json</format-->
<!-- CucumberOptions.strict property -->
<!-- strict>true</strict>-->
<!-- CucumberOptions.monochrome property -->
<monochrome>true</monochrome>
<!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "#tag1","#tag2" and ORed tags like "#tag1,#tag2,#tag3" -->
<tags />
<!-- If set to true, only feature files containing the required tags shall be generated. -->
<filterFeaturesByTags>false</filterFeaturesByTags>
<!-- Generate TestNG runners instead of default JUnit ones. -->
<useTestNG>false</useTestNG>
<!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->
<namingScheme>simple</namingScheme>
<!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.-->
<namingPattern>Parallel{c}IT</namingPattern>
<!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->
<parallelScheme>FEATURE</parallelScheme>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.7</source>
<target>1.7</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<argLine>-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
-Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter"</argLine>
<properties>
<property>
<name>listener2</name>
<value>/core-automation/src/test/java/testRunner/CustomAllureListener</value>
</property>
</properties>
<forkCount>10</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*IT.class</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<versionRange>[1.0-alpha-2,)</versionRange>
<goals>
<goal>read-project-properties</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<versionRange>[4.1.0,)</versionRange>
<goals>
<goal>generateRunners</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I noticed that when generate parallel .IT files to run my tests in parallel, they each reference:
plugin = {"json:C:/Users/sy/git/censor/censor/target/cucumber-parallel/1.json"}
Still a tad confused with that because when running inside eclipse -> Run as: Maven Build... -> clean test I do not have these json files created, only when passing in command like mvn args do I get them
Looking more closely, its specifically when I pass in -Dcucumber.Options for tags in the mvn call, seems to be overwriting the -Dcucumber.options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter" that is inside my surefire plugin in the pom.xml
Thanks for your time, any help is greatly appreciated.
After a long morning I've figured out the problem, it was simply my passing of -Dcucumber.options with tags was overwriting the maven surefire argLine for the allurereporter.
Fixed by running with the following:
call mvn clean test -Dbrowser=Chrome -DseleniumEnvironment=local -Dcucumber.Options="--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter --tags #censoredtag"
call mvn allure:report
and removing the -Dcucumber.Options argLine from my maven surefire plugin.
I have created multi-module CQ5 Maven project. My Cq version is 5.5 and Java version is 6.
These are the steps that I have followed.
Created maven multi-module CQ maven project
Imported it in eclipse
Used VLT to import an existing project from repository into maven.
Converted the project to faceted form so the bundle part works fine.
In the content module I am trying to use JspC Plugin I have added the correct plugin info and dependencies in the respective POM files.
The Problem is that when I compile JspC says that global.jsp is not found
So I imported /libs also in my project and made sure that the libs is not included in built. By excluding the /libs folder. I referred this link Adding /libs
My JSPs have the default autocomplete feature in them but they don't recognise any CQ objects like the ones defined in <cq:defineObjects /> WHY ??
I referred this Link Autocomplete in JSP
My Directory Structure
My Content POM is as follows
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- ====================================================================== -->
<!-- P A R E N T P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->
<parent>
<groupId>supplierportal</groupId>
<artifactId>supplierportal</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<!-- ====================================================================== -->
<!-- P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->
<artifactId>supplierportal-content</artifactId>
<packaging>content-package</packaging>
<name>Supplier Portal Package</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>supplierportal-bundle</artifactId>
<version>${project.version}</version>
</dependency>
<!-- My Dependencies -->
<!-- Dependencies for Maven JSPC Starts -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId>
<version>2.0.0</version>
<!-- javax.jcr -->
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.day.cq</groupId>
<artifactId>cq-commons</artifactId>
<version>5.5.0</version>
<!-- com.day.cq.commons -->
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-commons</artifactId>
<version>5.5.2</version>
<!-- com.day.cq.wcm.commons -->
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-api</artifactId>
<version>5.5.0</version>
<!-- com.day.cq.wcm.api -->
</dependency>
<dependency>
<groupId>com.day.commons</groupId>
<artifactId>day-commons-jstl</artifactId>
<version>1.1.4</version>
<!-- javax.servlet.jsp.jstl.core -->
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-taglib</artifactId>
<version>5.5.0</version>
<!-- com.day.cq.wcm.tags -->
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
<version>2.2.0</version>
<!-- org.apache.sling.scripting.jsp.taglib -->
</dependency>
<dependency>
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.xssprotection</artifactId>
<version>5.5.14</version>
<!-- com.adobe.granite.xss -->
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-core</artifactId>
<version>5.5.6</version>
<!-- com.day.cq.wcm.core.components -->
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
<!-- org.apache.commons.lang3 -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.10</version>
</dependency>
<!-- Ends -->
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/content/jcr_root</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/.vlt</exclude>
<exclude>**/.vltignore</exclude>
<exclude>libs/</exclude>
</excludes>
</resource>
</resources>
<!-- Autocomplete Plugin config comes here -->
<!-- THis is Completely different Stuff... An Attempt to bring autocomplete feature in JSP -->
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.sling</groupId>
<artifactId>maven-jspc-plugin</artifactId>
<versionRange>[2.0.6,)</versionRange>
<goals>
<goal>jspc</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<versionRange>[2.4.1,)</versionRange>
<goals>
<goal>clean</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<!-- Autocomplete Ends -->
<!-- Ends Autocomplete -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</plugin>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<group>supplierportal</group>
<filterSource>src/main/content/META-INF/vault/filter.xml</filterSource>
<embeddeds>
<embedded>
<groupId>${project.groupId}</groupId>
<artifactId>supplierportal-bundle</artifactId>
<target>/apps/supplierportal/install</target>
</embedded>
</embeddeds>
<targetURL>http://${crx.host}:${crx.port}/crx/packmgr/service.jsp</targetURL>
</configuration>
</plugin>
<!-- Here I add code for JSPc Plugin -->
<!-- start -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jsps-to-compile</outputDirectory>
<resources>
<resource>
<directory>src/main/content/jcr_root</directory>
<excludes>
<exclude>libs/**</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-jspc-plugin</artifactId>
<version>2.0.6</version>
<executions>
<execution>
<id>compile-jsp</id>
<goals>
<goal>jspc</goal>
</goals>
<configuration>
<jasperClassDebugInfo>false</jasperClassDebugInfo>
<sourceDirectory>${project.build.directory}/jsps-to-compile</sourceDirectory>
<outputDirectory>${project.build.directory}/ignoredjspc</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>remove-compiled-jsps</id>
<goals>
<goal>clean</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${project.build.directory}/jsps-to-compile</directory>
<directory>${project.build.directory}/ignoredjspc</directory>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
<!-- end -->
<!-- Ends JSPC plugin config -->
</plugins>
</build>
<profiles>
<profile>
<id>autoInstallPackage</id>
<build>
<plugins>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<executions>
<execution>
<id>install-content-package</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>autoInstallPackagePublish</id>
<build>
<plugins>
<plugin>
<groupId>com.day.jcr.vault</groupId>
<artifactId>content-package-maven-plugin</artifactId>
<executions>
<execution>
<id>install-content-package-publish</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<targetURL>http://${publish.crx.host}:${publish.crx.port}/crx/packmgr/service.jsp</targetURL>
<username>${publish.crx.username}</username>
<password>${publish.crx.password}</password>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
#Vincent I couldn't answer you question in comments so I am giving you a detailed answer to you comment here.
To import /lib/foundations you have a create an EXTRA file filter-vlt.xml under
{yourproject}\content\src\main\content\META-INF\vault\filter-vlt.xml
In filter-vlt.xml this you have to enter
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/libs/foundation"/>
<filter root="/apps/myapp"/>
<filter root="/etc/designs/myapp"/>
<filter root="/etc/designs/bootstrap-custom-version2"/>
</workspaceFilter>
See entry of /libs/foundation.
Make sure you don't put this entry in filter.xml. This should be present in filter-vlt.xml
And your filter.xml entry will be like this.
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/apps/myapp"/>
<filter root="/etc/designs/myapp"/>
<filter root="/etc/designs/bootstrap-custom-version2"/>
</workspaceFilter>
i.e the /libs/foundation is not present in filter.xml
Then browse to {yourproject}\content\src\main\content\jcr_root and type
vlt up --force
This will import you /apps/myapp i.e your project into your file system along with
/libs/foundation but when you are building your project /libs/foundation will not be included in the build.
Conclusion:
filter-vlt.xml helps you import files from CQ repo to local drive(file system) that you need for compiling your project. But these files are not included when you do maven build or install into CQ repository(filesystem to CQ repo).
Only those files are pushed into CQ repository whose entry is present in filter.xml
I got it. I imported /libs/foundation in my content part of Maven project.
Then I added this in the maven-resources-plugin configuration
<resource>
<directory>src/main/content/jcr_root</directory>
<includes>
<include>apps/**</include>
<include>libs/foundation/global.jsp</include>
</includes>
</resource>
This configuration includes global.jsp in the compile process, so this helped all my Jsps that had included global.jsp in them to compile successfuly.
But it is also necessary to exclude the libs in the built other wise the whole /libs is included in the built.
To do that we must add this entry in content/pom.xml
<build>
<resources>
<resource>
<directory>src/main/content/jcr_root</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/.vlt</exclude>
<exclude>**/.vltignore</exclude>
<exclude>libs/</exclude>
</excludes>
</resource>
</resources>
I'm new into Groovy and I'm trying to write a very simple project using Groovy as language. I was able to write a hello world script, deploy an mvn artifact and execute it.
I'm going beyond that right now and I need to import some external libraries for testing matters but I don't know how to do that.
I would really appreciate if you could give me some tips about this.
Thanks!
You can specify dependencies for the project which have test scope, in which case they will not be used in compile scope, or you can specify dependencies which are only used in certain scenarios (if, for example, you want to write Groovy tests without requiring the rest of your team to do so).
This sample pom.xml has a custom profile element which describes dependencies and executions to run only if the current environment user is "andylopresto". This means that if my team doesn't want to use Groovy in their build, I could still write my test classes in Groovy and have them run as part of the standard mvn test phase on my machine only. In my team members' local machines (or a shared Jenkins instance), the Groovy test files will be ignored (not compiled or run, and the groovy-all dependency will not even be downloaded onto the machine).
Example:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>your.package</groupId>
<artifactId>artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<developers>
<developer>
<id>alopresto</id>
<name>Andy LoPresto</name>
<email>alopresto#example.com</email>
<roles>
<role>developer</role>
<role>owner</role>
</roles>
</developer>
<developer>
<id>jjava</id>
<name>Johnny Java</name>
<email>ihategroovy#example.com</email>
<roles>
<role>sticking to older languages</role>
</roles>
</developer>
</developers>
<dependencyManagement>
<dependencies>
<!-- This dependency is available to all project code -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<!-- This dependency is only available during test phase -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- This dependency is expected to be provided outside of Maven -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-util</artifactId>
<version>8.0.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<!-- Custom profile for Groovy tests used only on Andy's computer -->
<id>andyLocalTest</id>
<activation>
<property>
<name>env.USER</name>
<value>andylopresto</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.2.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/groovy</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
<source>1.6</source>
<target>1.6</target>
<includes>
<include>**/*.java</include>
<include>**/*.groovy</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.5-03</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
How can I use wsimport -clientjar in my POM.xml.
I am expecting this would download java sources, create Jar out of it and deletes the source.
Can you please give me an example POM for me?
Thank you.
I know its an old question but in case someone else is looking,
I am using this pom for my tests:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xerox.3dprinterfarm</groupId>
<artifactId>3DPrinterInterfaceTests</artifactId>
<version>1.0-SNAPSHOT</version>
<name>3D Printer Interface Tests</name>
<description>3D Printer Interface Tests</description>
<build>
<plugins>
<!-- use the jax-ws maven plugin-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>wsimport-from-jdk</id>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- using wsdl from an url -->
<wsdlUrls>
<wsdlUrl>
https://webservices.xerox.com/3dPrints?WSDL
</wsdlUrl>
</wsdlUrls>
<!-- or using wsdls file directory -->
<!-- <wsdlDirectory>src/wsdl</wsdlDirectory> -->
<!-- which wsdl file -->
<!-- <wsdlFiles> -->
<!-- <wsdlFile>myWSDL.wsdl</wsdlFile> -->
<!--</wsdlFiles> -->
<!-- Keep generated files -->
<keep>true</keep>
<!-- Package name -->
<packageName>com.xerox.3dprinterfarm</packageName>
<!-- generated source files destination-->
<sourceDestDir>target/generatedclasses</sourceDestDir>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Have a look at the JAX-WS Maven Plugin.