Only META-INF in JitPack dependencies - java

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.

Related

Failed to load resource error when starting Spring-Boot Application with Angular 7 Frontend (missing resources)

I want to build a Spring-Boot-Application with Angular frontend. So I used the Spring-Boot-Initializer to build up a project and added a RestController for /greet/world. Then I created a new Angular-Project in my src/main-folder by executing ng new ui (including routing and css).
I updated the output-Path in my angular.json to the following:
"outputPath": "../resources/static"
Then I added the Http-Get-Request in my app.component.ts and ran the following commands to build the jar:
ng build --prod from my src/main/ui
cd %back_to_project_root%
mvn clean package
cd target
java -jar Jar-file
When opening http://localhost:8080 I see the usual Angular-Startup-Page and the following console-log:
What did I do wrong when including my frontend into the backend? Running ng serve from my src/main/ui works perfectly fine.
My app.component.ts:
import { Component, OnInit } from '#angular/core';
import { HttpClient } from '#angular/common/http';
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'ui';
constructor(private http: HttpClient) { }
ngOnInit() {
this.http.get('http://localhost:8080/greet/world').subscribe( (data) => {
console.log('DATA', data);
this.title = 'try';
});
}
}
My HelloWorldController.java
package com.demo.example.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
#RequestMapping("/hello")
public class HelloWorldController {
#RequestMapping(value="/world")
public String greetWorld() {
return "Hello world";
}
}
My pom.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.hud</groupId>
<artifactId>HelloWorld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>HelloWorld</name>
<description></description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>ng</executable>
<workingDirectory>src/main/ui</workingDirectory>
<argument>
<argument>build</argument>
</argument>
</configuration>
</plugin>
</plugins>
</build>
</project>
Edit 1
I changed my output-path to ../../../target/static and then ran mvn clean package and ng build --prod afterwards.
Yet, this does not really save the day since these are not provided in the jar-file when running mvn clean package, but it solved the question for the moment.
Edit 2
I reworked my code like suggested and got the following stuff:
pom.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.test</groupId>
<artifactId>HelloWorld</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>HelloWorld</name>
<description></description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
<configuration>
<nodeVersion>v10.14.1</nodeVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>default-copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<!-- It must match the resulting war-file name -->
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/dist</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When executing mvn clean install from project-root I get the following error:
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:npm (npm install) on project HelloWorld: Failed to run task: 'npm install' failed.
java.io.IOException: Cannot run program "c:\Dev\wsp_test\HelloWorld\node\node.exe" (in directory "c:\Dev\wsp_test\HelloWorld"): CreateProcess error=2, System cannot find the file (<- this is translated, so might be different wording)-> [Help 1]
Open your angular.json file, set "outputPath" to ../../../dist
In your package.json, you should have a build script, example:
"scripts": {
[..]
"build": "ng build --prod",
}
Edit your pom.xml to add the frontend-maven-plugin plugin to build angular with maven, and maven-resources-plugin to copy them (How to setup angular 4 inside a maven based java war project)
:
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<configuration>
<nodeVersion>v8.9.0</nodeVersion>
</configuration>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.2</version>
<executions>
<execution>
<id>default-copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<!-- It must match the resulting war-file name -->
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/dist</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Using git-commit-id-plugin in maven works in package-phase but not in install-phase

I'm using the git-commit-id-plugin (see https://github.com/ktoso/maven-git-commit-id-plugin). It packages correctly when I'm setting up an annotated tag like e.g. v1.0.0, meaning the target-directory has a jar file named deploy-test-Test-v1.0.0.jar.
The problem is, that the maven install phase creates the following files in my local .m2-directory:
Test-${git.closest.tag.name}
|- deploy-test-Test-${git.closest.tag.name}.jar
|- deploy-test-Test-${git.closest.tag.name}.pom
|- _remote.repositories
I've tested this with the example pom.xml.
What can I do to get the same name (deploy-test-Test-v1.0.0.jar)?
<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.mytest</groupId>
<artifactId>deploy-test</artifactId>
<packaging>jar</packaging>
<version>Test-${git.closest.tag.name}</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>Test-${git.closest.tag.name}</revision>
</properties>
<dependencies/>
<build>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
<execution>
<id>validate-the-git-infos</id>
<goals>
<goal>validateRevision</goal>
</goals>
<!-- *NOTE*: The default phase of validateRevision is verify, but in case you want to change it, you can do so by adding the phase here -->
<phase>package</phase>
</execution>
</executions>
<configuration>
<!-- If you'd like to tell the plugin where your .git directory is, use this setting, otherwise we'll perform a search trying to figure out the right directory. It's better to add it explicitly IMHO. -->
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<prefix>git</prefix>
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
<dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<format>properties</format>
<skipPoms>true</skipPoms>
<injectAllReactorProjects>false</injectAllReactorProjects>
<failOnNoGitDirectory>true</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>true</failOnUnableToExtractRepoInfo>
<skip>false</skip>
<runOnlyOnce>false</runOnlyOnce>
<useNativeGit>false</useNativeGit>
<abbrevLength>7</abbrevLength>
<commitIdGenerationMode>flat</commitIdGenerationMode>
<gitDescribe>
<skip>false</skip>
<always>false</always>
<abbrev>7</abbrev>
<dirty>-dirty</dirty>
<match>*</match>
<tags>false</tags>
<forceLongFormat>false</forceLongFormat>
</gitDescribe>
<validationProperties>
<validationProperty>
<name>validating project version</name>
<value>${project.version}</value>
<shouldMatchTo>
<![CDATA[^.*(?<!-SNAPSHOT)$]]>
</shouldMatchTo>
</validationProperty>
</validationProperties>
<validationShouldFailIfNoMatch>true</validationShouldFailIfNoMatch>
<evaluateOnCommit>HEAD</evaluateOnCommit>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
To incorporate git-commit-id plugin into the version number for the entire maven build cycle (till deploy)
<properties>
<java.version>1.8</java.version>
<snapshot.string>-SNAPSHOT</snapshot.string>
<!-- Snapshot Version Number -->
<!-- <version.number>${git.commit.time}.${git.commit.id.abbrev}${s`enter code here`napshot.string}</version.number> -->
<!-- Release Version Number -->
<version.number>${git.commit.time}.${git.commit.id.abbrev}</version.number>
<release.repo.key>libs-release-local</release.repo.key>
<snapshot.repo.key>libs-snapshot-local</snapshot.repo.key>
<artifactory.url>http://xxx.xxx.x.xxx:yyyy/artifactory</artifactory.url>
<release.repository.url>${artifactory.url}/${release.repo.key}</release.repository.url>
<snapshot.repository.url>${artifactory.url}/${snapshot.repo.key}</snapshot.repository.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dateFormat>yyyyMMdd.HHmmss</dateFormat>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<generateGitPropertiesFile>false</generateGitPropertiesFile>
<injectAllReactorProjects>true</injectAllReactorProjects>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>change-version</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script>
< ![CDATA[
import org.apache.maven.artifact.versioning.VersionRange; git_revision = '${version.number}'
if (!project.properties['revision'] ? .trim()) {
println 'Change `version` to ' + git_revision
System.properties['revision'] = git_revision
project.properties['revision'] = git_revision
project.properties['project.version'] = git_revision
project.properties['git.build.version'] = git_revision
project.version = git_revision
project.artifact.version = git_revision
project.artifact.versionRange = VersionRange.createFromVersion(git_revision)
}
]] >
</script>
</scripts>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.14</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>release</id>
<name>local-releases</name>
<url>${release.repository.url}</url>
</repository>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>snapshots</id>
<name>local-snapshots</name>
<url>${snapshot.repository.url}</url>
</snapshotRepository>
</distributionManagement>
Also refer to this to work around the "plugin execution not covered by lifecycle" error in Eclipse/SpringToolSuite
see: How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds
I've found a solution that worked fine for me. Just added the gmaven-plugin like in the pom-snippet below and the versions will be adapted to the last git-tag.
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>project.artifact.version='${git.closest.tag.name}';</source>
</configuration>
</execution>
</executions>
I've also used groovy-maven-plugin to update project.properties. Without this pom.xml was generated with variables that have not been parsed.
project properties
<properties>
<gitClosestTagName>${git.closest.tag.name}</gitClosestTagName>
<gitClosestTagCommitCount>${git.closest.tag.commit.count}</gitClosestTagCommitCount>
</properties>
build final name atteribute
<finalName>${project.artifactId}-${gitClosestTagName}.${gitClosestTagCommitCount}</finalName>
plugin definition
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>update-finalname</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
project.build.finalName="${project.artifactId}-${gitClosestTagName}.${gitClosestTagCommitCount}";
project.properties['gitClosestTagName']=${git.closest.tag.name};
project.properties['gitClosestTagCommitCount']=${git.closest.tag.commit.count};
println("project.build.finalName=${project.build.finalName}");
</source>
</configuration>
</execution>
</executions>

Maven trying to deploy the same artifact twice

I'm using Maven to build my project, but when I run the command mvn clean package deploy, it tries to deploy the artifact twice. I have the build-helper-maven-plugin plugin configured to attach an ear file that I create using a custom plugin.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.artifactId}-${project.version}.ear</file>
<type>ear</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
When I disable build-helper-maven-plugin, the remaining artifact (only the pom) is uploaded only once.
What should I do to let Maven deploy the extra ear file only once?
Erates
EDIT
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.group.id</groupId>
<artifactId>my.artifact.id</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>My Project</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<scm>
<!-- Config -->
</scm>
<distributionManagement>
<repository>
<!-- Config -->
</repository>
<snapshotRepository>
<!-- Config -->
</snapshotRepository>
</distributionManagement>
<dependencies>
<!-- My Dependencies here -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeGroupIds>my.group.ids.that.need.to.be.included</includeGroupIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>my.group.id</groupId>
<artifactId>my.custom.plugin</artifactId>
<version>1.0.1</version>
<configuration>
<params>
<!-- My params -->
</params>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>my-custom-goal</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Release Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4</version>
<configuration>
<goals>clean package deploy</goals>
<tagBase>https://my.tagbase</tagBase>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.artifactId}-${project.version}.ear</file>
<type>ear</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
<!-- My Modules -->
</modules>
</project>
First you are using module and trying to do weird things in your parent pom (dependency-plugin, build-helper etc.). In a parent there should never be an execution like you have in your pom. You should make the appropriate configuration/execution within the appropriate modules cause this definition will be inherited of all childs.
Would you like to create an ear file? Than you should use packaging ear and your ear file will simply being deployed by using mvn deploy.
Furthermore you seemed to misunderstand the life cycle cause if you call:
mvn clean package deploy
this can be reduced to:
mvn clean deploy
cause the package life cycle is part of deploy so i recommend to read the life cycle information.

global.jsp not found in Maven project while using JspC in CQ5 Archtype?

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>

Automatically creation of test databases using Maven

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>

Categories

Resources