I'd like to use properties-maven-plugin. I read the usage http://mojohaus.org/properties-maven-plugin/usage.html , but it's not working for me.
I created a very simple project to test it. Here is my 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>test</groupId>
<artifactId>MavenTest</artifactId>
<version>1.0.0</version>
<name>MavenTest</name>
<properties>
<prop1>2.2</prop1>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<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>${basedir}/my.properties</file>
</files>
</configuration>
</execution>
</executions>
</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></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
If I run mvn compile, or mvn install the result is:
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.apache.logging.log4j:log4j-api:jar must be a valid version but is '${log4j.version}'. # line 16, column 13
The "my.properties" file contains this:
log4j.version=2.2
As it described here: mojohaus
If I use the prop1 property, which is defined in the pom.xml, everything is working.
So what I'm doing wrong?
Official answer from them is that using read-project-properties for setting version of dependencies is not supported: https://github.com/mojohaus/properties-maven-plugin/issues/26
This does not work nor is it the intention of properties maven plugin and furthermore what would be the advantage to read properties from a file to define versions of dependencies?
There is a very through explanation about this issue on this answer: https://stackoverflow.com/a/14727072/1707491
Make sure that you have ${basedir}/my.properties file present with that specific property value pair:
my.properties contents should be:
prop1=2.3
You have to define the version properties when you want to use them. The plugin just allows you to do so; but you will have to set the values for yourself.
Like
<properties>
<log4j.version>1.2.17</log4j.version>
</properties>
EDIT:
As you showed, you have done that. Now it seems, that as you defined the goal within an execution, it is only valid within that execution.
Try to declare it as global:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<configuration>
<files>
<file>${basedir}/my.properties</file>
</files>
</configuration>
...
The maven way is to use the element in a top level POM that includes the projects with common dependencies. That is the simplest approach.
You can also import a POM used expressly for dependency managment. The import approach does not require the parent/child project relationships.
See the Maven documentation:
Dependency Management
Importing Dependencies
Related
I can't use the scala-maven-plugin to build my Java-sources due to a bug in Scalac (https://issues.scala-lang.org/browse/SI-9853).
Splitting the build so that Java is compiled by the maven-compiler-plugin and Scala by the scala-maven-plugin was easy enough with the sources residing in src/main/java and src/main/scala.
Right now I am running into the problem that the Scala-classes can't see the Java-classes.
When doing mvn clean compile I get 'not found' for all Java-classes required by the Scala-classes. Checking 'target/classes' shows that the Java-classes are there.
I tried moving the Scala-build to different phases but the results remain the same.
How can I make the Scala-build see the classes already available in target/classes?
<?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>de.codepitbull.maven</groupId>
<artifactId>maven-scalac-bug</artifactId>
<version>3.4.0-SNAPSHOT</version>
<name>Scalac + Javac</name>
<properties>
<scala.version>2.11.8</scala.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<scope>provided</scope>
<version>${scala.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<sendJavaToScalac>false</sendJavaToScalac>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-feature</arg>
<arg>-deprecation</arg>
<arg>-explaintypes</arg>
<arg>-unchecked</arg>
<arg>-Xlint</arg>
</args>
</configuration>
<executions>
<execution>
<id>java-compile-first</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The easiest workaround would be to split it into two submodules. That way you're able to reference the Java classes as dependency. After that generate an Uber jar or shaded jar with both modules inlined.
I am new to Maven and an using it to build my Java project. I have two questions:
I was able to successfully compile my project with Maven but Eclipse still reports compile time errors. I know these errors are because I have not added external jars to Eclipse's build path, but is there any other way I can resolve these errors?
How do I run my Java project with Maven?
Here's my pom.xml file:
<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.springhibernate</groupId>
<artifactId>SpringHibernateAssignment</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringHibernateAssignment</name>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>com.springhibernate</groupId>
<artifactId>SpringHibernateAssignment</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<file>${basedir}/lib/ojdbc14.jar</file>
</configuration>
</execution>
</executions>
</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.apache.maven.plugins
</groupId>
<artifactId>
maven-install-plugin
</artifactId>
<versionRange>
[2.4,)
</versionRange>
<goals>
<goal>install-file</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
The m2e plug in for Eclipse will integrate Maven so that Eclipse will automatically include JAR's from the local Maven cache based on the contents of the POM.xml.
And excluding all Java source files explains why Maven's build succeeds without any dependencies.
Put the third party libraries as dependencies in your pom.xml.
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxr-api</artifactId>
<version>1.0</version>
</dependency>
<dependencies>
You can find them in here.
If those jars you mention are public frameworks, you should be able to find them in the maven central repository and add them to your project just like Eranda explained. If you have jars that cannot be found publicly, you have to add them first to your local maven repo using maven install-file plugin: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
May be your M2_Home is not set, can you confirm. You may be building the project from the command line not from the eclipse ( Guess).
Suggestions:
1. Set M2_HOME.
2. Clean or Build the Project from eclipse, it will add all your dependent jars to references
I have a third-party jar that is a dependency of my project. Because of business constraints, I do not have access to an enterprise or company repository, which would definitely be my preference for this issue. But regardless, this third-party jar is not available publicly, and so it is included in the web project under src\main\resources.
This is a Maven project, and so I list this third-party jar as a compile time dependency, and include in my pom a build plugin that will install the third-party jar to my local repository as part of the build process; I tell Maven to perform this goal during the validate phase of the build lifecycle, which to my knowledge would be before any other Maven phase.
However, when I run a clean install and have my local repository cleared out, the build fails due to the third-party jar not being resolvable locally or in the Maven central repository. As far as I know, I have set up the pom correctly and I should be seeing Maven attempt to install the third-party jar locally before it begins dependency resolution.
The issue is that if the dependency is listed before the jar has ever been installed locally, the build will fail due to being unable to resolve that dependency. If I remove the third-party jar declaration and run the build, after dependency resolution occurs (which is the very first thing it does after the clean), but before any other phase, it will locally install the jar and things are fine. But to my knowledge, it should run the validate phase before it collects and resolves dependencies, and so the jar should be locally installed before it's resolved by Maven. Any ideas or thoughts?
My pom:
<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>com.company</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Web Services</name>
<description>This project will handle communication.</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- This plugin installs the Evip jar from the project's resource folder to the local
repository for normal Maven consumption -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-evip-jar</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>install:install-file</argument>
<argument>-Dfile=${basedir}\src\main\resources\EVIPSoapServer.jar</argument>
<argument>-DgroupId=com.company</argument>
<argument>-DartifactId=EVIPSoapServer</argument>
<argument>-Dversion=1.0.0</argument>
<argument>-Dpackaging=jar</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<!-- EXCLUDE EVIPSOAPSERVER JAR FROM CLASSES DIRECTORY -->
<packagingExcludes>
${basedir}\src\main\resources\EVIPSoapServer.jar
</packagingExcludes>
<webResources>
<!-- INCLUDE SOURCE FILES WITH WAR -->
<resource>
<directory>${project.build.sourceDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<!-- mvn clean install tomcat:run-war to deploy Look for "Running war
on http://xxx" and "Setting the server's publish address to be /yyy" in console
output; WSDL browser address will be concatenation of the two: http://xxx/yyy?wsdl -->
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>start-tomcat</id>
<goals>
<goal>run-war</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<port>${test.server.port}</port>
<path>/webservice</path>
<fork>true</fork>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<!--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>
exec-maven-plugin
</artifactId>
<versionRange>
[1.2.1,)
</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-- COMPILE DEPENDENCIES -->
<dependency>
<groupId>com.company</groupId>
<artifactId>EVIPSoapServer</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- PROVIDED/TEST DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The solution from http://randomizedsort.blogspot.com.es/2011/10/configuring-maven-to-use-local-library.html is based on having a file-based, project-scoped maven repository. Thus, the library is under your source code versioning. Install is one-time manual process, rather than a something specified in the pom.xml file
Three steps:
Create a folder in your project where you will keep the repo. Say lib.
Use Maven to install your jar to the lib directory.
mvn install:install-file -Dfile=path_to_mylib.jar ^
-DgroupId=com.mylib ^
-DartifactId=mylib ^
-Dversion=1.0 ^
-Dpackaging=jar ^
-DlocalRepositoryPath=path_to_my_project/lib
3.Update your pom.xml
<repositories>
<repository>
<!-- DO NOT set id to "local" because it is reserved by Maven -->
<id>lib</id>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.mylib</groupId>
<artifactId>mylib</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Saw this question while looking for a solution to a similar problem. I know it's old, but wanted to share my solution. I ended up solving my problem by using the maven-install-plugin directly:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>whatevs</id>
<phase>validate</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>${oracle.version}</version>
<packaging>jar</packaging>
<file>${basedir}/dev-setup/lib/ojdbc6.jar</file>
</configuration>
</execution>
</executions>
</plugin>
Works perfectly.
I suggest you modeling the external dependency as a separate project (think of it as a wrapper). Your current project may then be dependent on your own project that as part of its build can download the external JAR and package it into its own distributable.
Alrighty, arguing and preference aside, I did go with Sander's recommendation; it was the only one that really worked without custom Mojos, etc. I have a parent Maven project with a packaging of type pom and all it does is install the third-party jar (which could be any number of jars or dependencies) to my local repository. The parent pom:
<?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>com.company</groupId>
<artifactId>project-evip</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>EvipSoapServerJar</name>
<packaging>pom</packaging>
<modules>
<module>webservices</module>
</modules>
<build>
<plugins>
<!-- This plugin installs the Evip jar from the project's lib to the local
repository for normal Maven consumption -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-evip-jar</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>install:install-file</argument>
<argument>-Dfile=${basedir}\src\main\resources\EVIPSoapServer.jar</argument>
<argument>-DgroupId=com.company</argument>
<argument>-DartifactId=EVIPSoapServer</argument>
<argument>-Dversion=1.0.0</argument>
<argument>-Dpackaging=jar</argument>
</arguments>
</configuration>
</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>
exec-maven-plugin
</artifactId>
<versionRange>
[1.2.1,)
</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Then, I created a Maven module under the parent Maven project and used the org.apache.cxf.archetype:cxf-jaxws-javafirst:2.7.7 archetype. I simply list the third-party jar as a compile-time dependency, and it's resolved and added to the resulting war. The child module's pom:
<?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>
<parent>
<artifactId>project-evip</artifactId>
<groupId>com.company</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.company</groupId>
<artifactId>webservices</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Web Services</name>
<description>This project will handle communication.</description>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<!-- INCLUDE SOURCE FILES WITH WAR -->
<resource>
<directory>${project.build.sourceDirectory}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<!-- mvn clean install tomcat:run-war to deploy Look for "Running war
on http://xxx" and "Setting the server's publish address to be /yyy" in console
output; WSDL browser address will be concatenation of the two: http://xxx/yyy?wsdl -->
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>start-tomcat</id>
<goals>
<goal>run-war</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<port>${test.server.port}</port>
<path>/webservice</path>
<fork>true</fork>
<useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<projectNameTemplate>[artifactId]-[version]</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-- COMPILE DEPENDENCIES -->
<dependency>
<groupId>com.company</groupId>
<artifactId>EVIPSoapServer</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.7.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- PROVIDED/TEST DEPENDENCIES -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I appreciate all the help, thank you.
Corresponding to gregm's answer I'm using now:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
This installs the JAR of the project itself to local repository.
Result:
--- maven-jar-plugin:2.3.2:jar (default-jar) # SportyLib ---
Building jar: ...-1.0-SNAPSHOT.jar
--- maven-install-plugin:2.5.2:install (default-install) # SportyLib ---
Installing ...-1.0-SNAPSHOT.jar to .../.m2/repository/.../1.0-SNAPSHOT/...-1.0-SNAPSHOT.jar
Installing .../pom.xml to .../.m2/repository/.../1.0-SNAPSHOT/...-1.0-SNAPSHOT.pom
This must be mostly a newbie Maven question.
Since SwingX migrated to Kenai, there are warnings all over the website that many links are broken.. so here is my best attempt.
I went to https://java.net/projects/swingx/downloads/directory/releases
Clicked on "SwingX 1.6.4 All - Sources" (really a non-intuitive, hit-or-miss choice for me, but perhaps it's a naming convention other people understand?)
This downloads swingx-all-1.6.4-sources.jar (why is it even a jar and not a zip?)
However, this source jar does not contain POM.XML.
So, I downloaded swingx-all-1.6.4.jar from the same link, renamed it to .zip, inflated. It does contain
META-INF\maven\org.swinglabs.swingx\swingx-all\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>
<parent>
<artifactId>swingx-project</artifactId>
<groupId>org.swinglabs.swingx</groupId>
<version>1.6.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>swingx-all</artifactId>
<packaging>jar</packaging>
<name>SwingX Complete</name>
<description>A Maven project to aggregate all modules into a single artifact.</description>
<properties>
<project.generatedDependencies>${project.generatedSourcesDirectoy}/dependencies</project.generatedDependencies>
</properties>
<!-- make the dependent swingx modules optional, since we're aggregating -->
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-graphics</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-core</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>swingx-mavensupport</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
<profiles>
<profile>
<id>jvnet-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>src-dependencies</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<classifier>sources</classifier>
<includeGroupIds>${project.groupId}</includeGroupIds>
<excludeArtifactIds>swingx-mavensupport</excludeArtifactIds>
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
<outputDirectory>${project.generatedDependencies}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>add-dependencies-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.generatedDependencies}</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-dependencies-resource</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.generatedDependencies}</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.generatedAnnotations}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
When I change to the above directory where POM.XML is located and do mvn install, it certainly builds a lot of stuff.. but also says:
[INFO] skip non existing resourceDirectory
F:\swingx\swingx-all-1.6.4\META-INF\m
Maven\org.swinglabs.swingx\swingx-all\src\main\resources
That's because the src directory is nonexistent. Which makes sense, because the .jar files in question is said to be binaries only, but I was hoping some Maven target would download sources or something... and if it's binary only, why does it need to be built? Confused.
At that point, I could probably either copy the src directory from the first zip file to the second, or copy the pom.xml from the second file to the first.. but I am having a feeling I am missing something, and there has to be a more straightforward way.
BTW, there is a third file at the same web page, swingx-mavensupport-1.6.4.jar
So I downloaded that, renamed it to .zip, inflated, found this file:
META-INF\maven\org.swinglabs.swingx\swingx-mavensupport\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>
<parent>
<artifactId>swingx-project</artifactId>
<groupId>org.swinglabs.swingx</groupId>
<version>1.6.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>swingx-mavensupport</artifactId>
<name>SwingX Maven Support</name>
</project>
Changed to its directory and ran mvn.install
However, that complained at the lack of a whole lot of files.
I must be getting it all wrong. What's the right way?
Use the following URL for SVN checkout: https://svn.java.net/svn/swingx~svn.
In trunk there is a correct pom.xml file (actualy many of them for different artifacts), so you can easily build the project yourself.
swingx-all-1.6.4-sources.jar (why is it even a jar and not a zip?)
That's the default way sources are packaged and distributed in Maven.
I'm a newbee in apache Maven. When i try to read the values from the properties file, it's not picking the value. I already seen all the previously asked questions in SO. But no luck with that. This is my property file.
nameofmayil=mayilsamy
This is the 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>com.mycompany.mayil</groupId>
<artifactId>mayil-app</artifactId>
<version>1.0.1</version>
<packaging>jar</packaging>
<name>mayil-app</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
<scm>
<connection>scm:svn:http://127.0.0.1/svn/my-project</connection>
<developerConnection>scm:svn:https://127.0.0.1/svn/my-project</developerConnection>
<tag>HEAD</tag>
<url>http://127.0.0.1/websvn/my-project</url>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<!-- Associate the read-project-properties goal with the initialize phase, to read the properties file. -->
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/buildNumber.properties</file>
<file>${basedir}/mayil.properties</file>
</files>
<quite>false</quite>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Displaying value of properties</echo>
<echo>${nameofmayil}</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The property file is loaded properly, i checked with that.
The POM shown has the properties-maven-plugin execution bound to the initialize phase, and the antrun plugin goal displaying the properties bound to the validate phase. initialize comes after validate (per the Maven lifecycle docs) which is why you're not seeing the results you want. You may fix in a couple of ways:
bind the properties-maven-plugin goal to the validate phase OR
bind the maven-antrun-plugin goal to the initialize phase
Both of the above have goals bound to the same phase. This is fine, as long as the goals are listed in the POM in the order you want them to execute. If you want them bound to distinct phases, perform both steps.