Android Studio Cloud Endpoint project Maven enhance goal fails with command line too long - maven

Using Android Studio, I have created an Android project with a cloud endpoint backend (Tools > Google Cloud Endpoints > Generate AppEngine Backend). The initial setup works and I am able to have the Android app see the exposed cloud endpoints.
However after adding more components to the AppEngine project (more entities, endpoints, servlets, etc) the AppEngine build fails during the Maven goal appengine-maven-plugin:enhance with a command line too long error.
Upon researching this, it appears this goal delegates to the datanucleus-maven-plugin:enhance goal (please see the Maven mojo source code here). When I run the goal from the command line using Maven's -X option, I see that the enhancer attempts to run on all classes (servlets, non-entities, etc) and that the command line length exceeds Window's limit.
The solution to this appears to be specifying only the specific entities to be enhanced. This post describes how the Maven plugin can be configured for that.
This all seems fair enough, but my attempts to configure the plugin from my pom.xml have no effect. Executing from the command line, I see the message that the datanucleus enhance goal is configured with it's default configuration and not from the pom.
I am a Maven newbie, so it'd be very much appreciated if someone could explain what the Maven appengine enhance mojo is expecting for a configuration which the source code seems to be grabbing in the line 115: mojoDescriptor.getMojoConfiguration()
My pom.xml looks like this:
<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>
<packaging>war</packaging>
<version>1.0</version>
<groupId>com.myproject</groupId>
<artifactId>MyProject</artifactId>
<properties>
<appengine.target.version>1.8.3</appengine.target.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--Found by examining mvn com.google.appengine:appengine-maven-plugin:1.8.3:enhance -X
see https://code.google.com/p/appengine-maven-plugin/source/browse/src/main/java/com/google/appengine/AppengineEnhancerMojo.java?spec=svn834b839bf5deab60499ecfb85facd55f06f8e258&r=834b839bf5deab60499ecfb85facd55f06f8e258
-->
<appengine.enhancerApi>JPA</appengine.enhancerApi>
</properties>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${appengine.target.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-endpoints</artifactId>
<version>${appengine.target.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>net.sf.jsr107cache</groupId>
<artifactId>jsr107cache</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.ganyo</groupId>
<artifactId>gcm-server</artifactId>
<version>1.0.2</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${appengine.target.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${appengine.target.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>3.2.0-release</version>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application-->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes
</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>2.5.1</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webXml>
${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml
</webXml>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>
${project.build.directory}/generated-sources/appengine-endpoints
</directory>
<!-- the list has a default value of ** -->
<includes>
<include>WEB-INF/*.discovery</include>
<include>WEB-INF/*.api</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<!--
No config settings get applied?
-->
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>3.2.0-release</version>
<configuration>
<fork>false</fork>
<verbose>true</verbose>
<metadataIncludes>some_path</metadataIncludes>
</configuration>
<executions>
<execution>
<id>default-enhance</id>
<configuration>
<fork>false</fork>
<verbose>true</verbose>
<metadataIncludes>some_path</metadataIncludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.8.3</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
</configuration>
<executions>
<execution>
<goals>
<goal>endpoints_get_discovery_doc</goal>
<!--goal>endpoints_get_client_lib</goal-->
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>3.2.0-release</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Thanks!

Related

Maven Surefire not detecting Junit5

I have a very simple Maven project that I updated here, I obtained it simplifying my real project:
GitHub repository
I need to run Surefire plugin to compile tests, so they can be used by Jacoco. I tried sooo many things, even changing/reducing the dependencies, but none worked!
I excluded the tests in maven-compiler-plugin because it said "package main.it.isp.utility does not exist". I don't know if excluding it is correct, though....
This is my pom.xml and project structure:
<?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>it.isp.batch</groupId>
<artifactId>Estrazioni-Batch</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<!-- Dependency versions -->
<junit.jupiter.version>5.5.2</junit.jupiter.version>
<!-- Java 8 -->
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<java.version>1.8</java.version>
<!-- Encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-engine</artifactId>
<version>5.0.0-ALPHA</version>
</dependency>
<!-- Jupiter API for writing tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.8.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.18</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.3.18</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<finalName>Estrazioni-Batch</finalName>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<resource>
<directory>src/</directory>
<excludes>
<exclude>test/</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<outputDirectory>${basedir}/target/diraliases/BATCHROOT/Estrazioni-batch/classes</outputDirectory>
<testExcludes>
<testExclude>**/*Test*</testExclude>
</testExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<skip>false</skip> <!-- Please take care of these parameters. They will help you to spot failure
in test assertions -->
<skipTests>false</skipTests>
<testSourceDirectory>${basedir}/src/main/test/</testSourceDirectory>
<properties>
<property>
<name>surefire.testng.verbose</name>
<value>10</value>
</property>
</properties>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0-M1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-api -->
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-api</artifactId>
<version>3.0.0-M6</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<!-- Suggested to always use the latest, at minimun 0.8.3 -->
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- EXEC format is still used as an intermediate report format, but
it purpose is only internal to JaCoCo execution -->
<!-- It will not be parsed by Sonar. There will be one EXEC file for
each module of the application -->
<destFile>./jacoco-${project.artifactId}.exec</destFile>
</configuration>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- The purpose of REPORT goal is to convert each EXEC in evry output
format that JaCoCo is able to produce, including XML -->
<!-- The XML files are placed inside a temporary directory -->
<dataFile>./jacoco-${project.artifactId}.exec</dataFile>
<outputDirectory>./sonar-report/temp-jacoco-xml/${project.artifactId}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>copy-file</id>
<phase>verify</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<!-- The purpose of this plugin is to collect all the XML files under
the temp directory in each module -->
<!-- and copy in to the right path scanned by Sonar. There will be
one XML file for each module -->
<sourceFile>./sonar-report/temp-jacoco-xml/${project.artifactId}/jacoco.xml</sourceFile>
<destinationFile>./sonar-report/jacoco-xml/jacoco-${project.artifactId}.xml</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The most important thing is to follow conventions in Apache Maven. So do not change the configuration for source directory and the test directory that makes in 99.999% of the cases no sense.
So first remove the following configuration parts:
<finalName>Estrazioni-Batch</finalName>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
The <finalName> ..</finalName> does not make sense because your artifact is named based on your artifactId...furthermore an artifactId should be lowercase.
You have configured either Eclipse wrong or it's based on the wrong configuration.
The production code belongs to src/main/java/<packageName> and the according unit- or integration tests should be done into src/test/java/<packageName>.
For unit tests you should follow naming conventions like *Test.java what you already did. And for integration tests you should use *IT.java.
Furthermore remove the configuration for the resources:
<resources>
<resource>
<directory>src/</directory>
<excludes>
<exclude>test/</exclude>
</excludes>
</resource>
</resources>
Because in your setup you've already used src/main/resources for test using src/test/resources.
Looking into the pom file you have given there are other strange things like mixing different junit-jupiter versions/parts.
So first remove the following from your pom file:
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit5-engine</artifactId>
<version>5.0.0-ALPHA</version>
</dependency>
<!-- Jupiter API for writing tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.8.2</version>
</dependency>
The easiest way to handle that is to use the junit bom file like the following:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
..
</dependencyManagement>
Afterwards you have to define a single dependency in your pom like this:
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
...
</dependencies>
Furthermore remove the whole setup/configuration of maven-surefire-plugin and replace with the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M6</version>
</plugin>
The whole configuration/setup of the maven-compiler-plugin should simply look like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
Also remove the whole configuration/setup of jacoco-maven-plugin and replace it with this:
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Remove the whole configuration/setup for copy-rename-maven-plugin.
Some words about usage of the dependencies:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
Why using different versions of the same artifact? Remove commons-lang:commons-lang:2.6 and continue to work with org.apache.commons:commons-lang3:3.12.0 instead.
If you like to use sonar report you should execute the sonar-maven-plugin which is described here: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/
There are full working example https://github.com/khmarbaise/example-junitjupiter
One final strong recommendation is to define the all the plugins which are used during the build (see the example)..

How to stop Maven upgrading to latest Google Cloud SDK

I have just deployed my latest code to GCP. I use maven and recently migrated from com.google.appengine 1.9.58 to the latest com.google.cloud.tools using appengine-maven-plugin.
The version I deployed last month was the Cloud SDK version 265.0.0. When I deployed my new code today it upgraded me to 267.0.0. How do I prevent this from happening and control which SDK version I'm on.
I tried adding a dependancy to my POM:
<dependency>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>265.0.0</version>
</dependency>
But this failed.
As per my comment, the Cloud SDK upgrades to the latest when I run mvn appengine:deploy or mvn appengine:run
Thanks
TimN
POM file:
<?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>
<packaging>war</packaging>
<version>1.0</version>
<groupId>com.company.app</groupId>
<artifactId>xxxyyydb</artifactId>
<properties>
<appengine.app.version>1</appengine.app.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<prerequisites>
<maven>3.6.1</maven>
</prerequisites>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>0.6</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.58</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify</artifactId>
<version>5.1.5</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.github.mpkorstanje</groupId>
<artifactId>simmetrics-core</artifactId>
<version>3.2.3</version>
</dependency>
</dependencies>
<build>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.2</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<projectId>xxxyyydb</projectId>
<version>1</version>
</configuration>
</plugin>
</plugins>
</build>
</project>
I found (and read!) the User Guide to the appengine-maven-plugin:
https://github.com/GoogleCloudPlatform/app-maven-plugin/blob/master/USER_GUIDE.md
Setting the cloudSdkVersion in the configuration section of the plugin in my pom.xml allowed me to force the SDK version. Without it, the plugin always downloads the latest Cloud SDK.
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<projectId>xxxyyyProjectID</projectId>
<version>1</version>
<cloudSdkVersion>267.0.0</cloudSdkVersion>
</configuration>
</plugin>

Maven try to download a <packaing>pom</package> pom as a jar file and cannot find it

my maven pom.xml is quite simple:
<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.acb</groupId>
<artifactId>adfafa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<!-- https://mvnrepository.com/artifact/org.pentaho/pentaho-aggdesigner -->
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner</artifactId>
<version>5.1.5-jhyde</version>
</dependency>
</dependencies>
</project>
From the pom.xml ,I just want pentaho-aggdesigner which is a parent pom of two modules pentaho-aggdesigner-core.jar and pentaho-aggdesigner-algorithm.jar , my remote repo is :http://repo.spring.io/plugins-release
so , I think ,maven will visit http://repo.spring.io/plugins-release/org/pentaho/pentaho-aggdesigner/5.1.5-jhyde/pentaho-aggdesigner-5.1.5-jhyde.pom to download the parent pom ,then , according to the pom, it will download two sub modules pentaho-aggdesigner-core.jar and pentaho-aggdesigner-algorithm.jar. The content of pentaho-aggdesigner-5.1.5-jhyde.pom is:
<?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>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner</artifactId>
<packaging>pom</packaging>
<version>5.1.5-jhyde</version>
<name>Pentaho Aggregate Designer</name>
<description>Designs aggregate tables for the Mondrian OLAP engine</description>
<url>http://github.com/pentaho/mondrian</url>
<inceptionYear>2006</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<repository>
<id>conjars</id>
<name>Conjars</name>
<url>http://conjars.org/repo</url>
<layout>default</layout>
</repository>
</distributionManagement>
<issueManagement />
<scm>
<connection>scm:git:git://github.com/julianhyde/pentaho-aggdesigner.git</connection>
<developerConnection>scm:git:git#github.com:julianhyde/pentaho-aggdesigner.git</developerConnection>
<url>http://github.com/julianhyde/pentaho-aggdesigner/tree/master</url>
<tag>pentaho-aggdesigner-5.1.5-jhyde</tag>
</scm>
<modules>
<module>pentaho-aggdesigner-algorithm</module>
<module>pentaho-aggdesigner-core</module>
</modules>
<dependencyManagement>
<!-- Dependency versions for all sub-modules.
Sorted by groupId, artifactId. -->
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
<version>5.1.5-jhyde</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>mondrian</artifactId>
<version>3.6.9</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1-beta-6</version>
</dependency>
<!-- Test dependencies. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-junit4</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock-legacy</artifactId>
<version>2.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
<version>5.1.5-jhyde</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>mondrian-data-foodmart-hsqldb</artifactId>
<version>0.2</version>
</dependency>
</dependencies>
</dependencyManagement>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<links>
<link>http://docs.oracle.com/javase/7/docs/api/</link>
</links>
</configuration>
</plugin>
</plugins>
</reporting>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>properties</id>
<goals>
<goal>properties</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- If we don't specify gitexe version, git doesn't
commit during release process. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
</plugins>
</build>
</project>
you can see , pom indicates clearly that I am not a jar pom but a package pom. But maven still consider it to be a jar pom and tries to download the pentaho-aggdesigner.jar from remote repo, of course , the jar file does not exist and throw this error:
[ERROR] Failed to execute goal on project adfafa: Could not resolve dependencies for project org.acb:adfafa:jar:0.0.1-SNAPSHOT: Could not find artifact org.pentaho:pentaho-aggdesigner:jar:5.1.5-jhyde in springmaven (http://repo.spring.io/plugins-release/) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project adfafa:
Could not resolve dependencies for project org.acb:adfafa:jar:0.0.1-SNAPSHOT: Could not find artifact org.pentaho:pentaho-aggdesigner:jar:5.1.5-jhyde in springmaven (http://repo.spring.io/plugins-release/)
I had the same issue with pentaho-aggdesigner:pom:5.1.5-jhyde, this site solved my problem
https://www.programmersought.com/article/76106349302/
Basically, used aliyun as mirror in maven settings.xml. And for this case, do not use repo.spring.io as mirror as it requires login and will have an "Authentication" error.
Nah, maven doesn't work like that. See also How to use POMs as a dependency in Maven?
A parent is just a trick to combine configuration for it's child modules. It doesn't automatically introduce transitive dependencies.
So you need to specify the exact jar dependencies. Probably something like:
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
<version>5.1.5-jhyde</version>
</dependency>
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-core</artifactId>
<version>5.1.5-jhyde</version>
</dependency>
There are pom's that you can use like this, by including type 'pom' in your dependency:
<dependency>
<groupId>xxx.yyy</groupId>
<artifactId>pentaho-all</artifactId>
<type>pom</type>
<version>XXXX</version>
</dependency>
In this case, pentaho-all would be a pom with a list of direct dependencies that you then would import as transitive dependencies. But the aggregator pom you found does not have direct dependencies, only modules and dependency management, so that one won't work.
adding following dependency to pom.xml will help
<!-- https://mvnrepository.com/artifact/org.pentaho/pentaho-aggdesigner-algorithm -->
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
<version>5.1.5-jhyde</version>
<scope>test</scope>
</dependency>
Just download the file from any available repo and store in the proper folder e.g.
~/.m2/repository/org/pentaho/pentaho-aggdesigner-algorithm/5.1.5-jhyde/pentaho-aggdesigner-algorithm-5.1.5-jhyde.jar

In Grails, the command "tomcat:deploy" does not generate the complete war as the command "dev war" does

The command "grails dev war" deploys perfectly in my local Tomcat6 server with a generated war which contains the next folders:
css
images
js
META-INF
plugins
WEB-INF
Unfortunately, I need that the command tomcat:deploy works too (I'm actually using: tomcat:redeploy -DskipTests). But Tomcat gives the next error:
2013-05-23 05:12:53,094 [http-8080-4] ERROR digester.Digester - Parse Fatal Error at line 1 column 1: Final de archivo prematuro.
org.xml.sax.SAXParseException; systemId: jndi:/localhost/Alojamiento/WEB-INF/web.xml; lineNumber: 1; columnNumber: 1; Final de archivo prematuro.
at
I added an empty web.xml in order to maven compiled. It is also empty in the generated war. So it is probably the cause of the problem ("grails dev war" generates a web.xml with code). Futhermore, the generated war only contains the next folders:
META-INF
WEB-INF
To be able to use "tomcat deploy", I added the next code to the pom.xml (after adding pom true, running "create-pom group" and other configuration changes):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://127.0.0.1:8080/manager</url>
<server>TomcatServer</server>
</configuration>
</plugin>
UPDATE 1
My full 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>alojamiento.ingenierosIW</groupId>
<artifactId>Alojamiento</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<name>Alojamiento</name>
<description>Alojamiento</description>
<properties>
<grails.version>2.2.2</grails.version>
</properties>
<dependencies>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-dependencies</artifactId>
<version>${grails.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-test</artifactId>
<version>${grails.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.grails</groupId>
<artifactId>grails-plugin-testing</artifactId>
<version>${grails.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>tomcat</artifactId>
<version>${grails.version}</version>
<scope>provided</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>spring-security-core</artifactId>
<version>1.2.7.3</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>cache</artifactId>
<version>1.0.1</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>resources</artifactId>
<version>1.2.RC2</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>db-reverse-engineer</artifactId>
<version>0.5</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>jquery</artifactId>
<version>1.8.3</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>database-migration</artifactId>
<version>1.3.2</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>hibernate</artifactId>
<version>2.2.2</version>
<scope>runtime</scope>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>tomcat</artifactId>
<version>2.2.2</version>
<scope>provided</scope>
<type>zip</type>
</dependency>
</dependencies>
<build>
<pluginManagement />
<plugins>
<!-- Disables the Maven surefire plugin for Grails applications, as we have our own test runner -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>plugins</directory>
<includes>
<include>**/*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>${grails.version}</version>
<configuration>
<!-- Whether for Fork a JVM to run Grails commands -->
<fork>true</fork>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<!--<ignorePackaging>true</ignorePackaging>-->
<addContextWarDependencies>true</addContextWarDependencies>
<url>http://127.0.0.1:8080/manager</url>
<server>TomcatServer</server>
<!--<username>admin</username>-->
<!-- <password>password</password>-->
<!-- <path>/u74937912-practica-WAR</path>-->
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>grails</id>
<name>grails</name>
<url>http://repo.grails.org/grails/core</url>
</repository>
<repository>
<id>grails-plugins</id>
<name>grails-plugins</name>
<url>http://repo.grails.org/grails/plugins</url>
</repository>
</repositories>
<profiles>
<profile>
<id>tools</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
It is perfectly working with this:
CONFIGURATION
Previously, if you are using Eclipse with the plugin m2e, here is explained how to configure Eclipse in order to use Tomcat with it:
tomcat-maven-plugin: Server returned HTTP response code: 403
Now, we need a proper settings.xml in the C:\Users\user.m2 with the same user and password than tomcat-users.xml. Then, we need to have our pom.xml configurated as follow:
<packaging>war</packaging>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://127.0.0.1:8080/manager</url>
<!-- The next server must be the same than the one in settings.xml (at C:\Users\user\.m2): -->
<server>TomcatServer</server>
</configuration>
</plugin>
<plugin>
<groupId>org.grails</groupId>
<artifactId>grails-maven-plugin</artifactId>
<version>${grails.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>init</goal>
<goal>maven-clean</goal>
<goal>validate</goal>
<goal>config-directories</goal>
<goal>maven-compile</goal>
<goal>maven-test</goal>
<goal>maven-war</goal>
<goal>maven-functional-test</goal>
</goals>
</execution>
</executions>
</plugin>
MAVEN COMMANDS TO DEPLOY:
The next command get the configuration values of our database from datasource.groovy - production environmnent:
tomcat:redeploy
tomcat:redeploy -DskipTests
grails:war tomcat:redeploy -DskipTests
To get the values from the development environment, the commands are the next:
grails:war tomcat:redeploy -Dgrails.env=development grails:war
tomcat:redeploy -Dgrails.env=development -DskipTests
Note1: if we not add -DskipTests (to no running tests before to deploying), and some test fail, it won't deploy.
Note2: in eclipse (with the plugin m2e for maven installed), you have to type these commands in the next field:
Run - Run Configurations - Maven Build - Goals
UPDATE 1
Do not forget to create an empty web.xml under src/main/webapp/WEB-INF!
UPDATE 2
Do not forget to tell Grails to use the pom.xml: http://grails.org/doc/2.3.x/ref/Command%20Line/create-pom.html
Try
mvn grails:war tomcat:redeploy -DskipTests
That should hopefully get grails to attach the correct WAR artefact to the build so that the empty default one is not uploaded.

Maven Plugin Development - Include Current Project's Resources to Plugin - "include-project-dependencies" - "NoSuchElementException"

I am trying to develop a maven plugin that uses resource files of the project that uses it as a plugin. I implemented that suggestion into my maven-plugin project and it was builded well. But when i clean & build my project that uses the plugin, i get this exception:
"Failed to execute goal
sample.plugin:maven-plugin:1.0-SNAPSHOT:convertproperties (default) on
project temp: Unable to retrieve component configurator
include-project-dependencies for configuration of mojo
sample.plugin:maven-plugin:1.0-SNAPSHOT:convertproperties:
java.util.NoSuchElementException
role: org.codehaus.plexus.component.configurator.ComponentConfigurator
roleHint: include-project-dependencies"
POM file of the maven-plugin:
<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>sample.plugin</groupId>
<artifactId>maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>maven-plugin</name>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>[1.5.0, 1.5.1 ]</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0.9</version>
<exclusions>
<exclusion>
<artifactId>maven-artifact</artifactId>
<groupId>org.apache.maven</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0.9</version>
<exclusions>
<exclusion>
<artifactId>maven-artifact</artifactId>
<groupId>org.apache.maven</groupId>
</exclusion>
<exclusion>
<artifactId>maven-repository-metadata</artifactId>
<groupId>org.apache.maven</groupId>
</exclusion>
<exclusion>
<artifactId>wagon-provider-api</artifactId>
<groupId>org.apache.maven.wagon</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
<version>1.0-beta-2</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
POM file of my project that uses the maven-plugin:
<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.mycompany</groupId>
<artifactId>temp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>temp</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>sample.plugin</groupId>
<artifactId>maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>convertproperties</goal>
</goals>
</execution>
</executions>
<configuration>
<sourcePath>/lang</sourcePath>
<destinationPath>lang_json</destinationPath>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>src\main\webapp\lang</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
Any help would be very useful, thanks.
I have found a very good solvation to use the resources of the project inside maven-plugin.
Firstly i gave up using that suggestion.
My plugin's aim was to convert some resource (.properties) files and save them into the location where jsp pages are stored inside the project. So, first step is to copy the needed resource files and rename them as needed by using another maven-plugin called "maven-antrun-plugin" by setting it like that:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>CopyLanguagePropertiesAsJson</id>
<phase>compile</phase>
<configuration>
<tasks>
<copy file="${basedir}\src\main\resources\x.properties"
tofile="${basedir}\src\main\webapp\x\y.z" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
After that movement, I send the opened properties file and destination file into my plugin as variables typed "file" and converted the properties file and stored into the converted file ==> x.properties --> y.z
I said opened because maven does the job exactly like tihs; at build time opens the files that are set as variables for some maven-plugins and sends those objects that are references of those files. The maven-plugin gains the ability to change those files by this way.
Like this:
<plugin>
<groupId>group.id</groupId>
<artifactId>artifact-id</artifactId>
<version>x.x.x</version>
<configuration>
<properties>
<file>${basedir}\src\main\resources\x.properties</file>
</properties>
<convertedFiles>
<file>${basedir}\src\main\webapp\x\y.z</file>
</jsons>
</convertedFiles>
</plugin>
And those files are taken inside the code (class extends AbstractMojo) of my plugin like this:
/**
* #parameter
*/
private File[] properties;
/**
* #parameter
*/
private File[] convertedFiles;
Those are the steps that fully achieves the aim on converting .properties files into another files and storing inside somewhere of a project.
In addition, i have faced with an exception that tells some classes are not found while executing the maven-plugin on the build time of the project which uses it. This is caused by not being able to find needed jar files of the maven-plugin at the build time of the current project. The solvation of that is to use plugin called "maven-assembly-plugin" that builds the jar of your maven-plugin including the dependency jar libraries that your maven-plugin uses. The configuration of the plugin inside the pom file of your maven-plugin :
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
If in some cases, the plugin fails to compile your jar as described, it may be caused by not containing a main class inside your maven-plugin. Because the resason to use such plugins that compile all jar files into one is to be bale to execute the jar of the current project alone itself, not needing any other classes on runtime (building standalone jar files). So, simply create a main class that uses the class of your maven-plugin (class extends AbstractMojo) and try to compile again. After a successfull compilation you can delete your main class, it would build your maven-plugin successfully again without a main class.
I vould be very happy if this post is helpful for somebody.

Resources