Showing posts with label maven 3. Show all posts
Showing posts with label maven 3. Show all posts

Thursday, June 25, 2015

how to create standalone maven project from command prompt

Windows
Set the environment variable
JAVA_HOME to C:\Program Files\Java\jdk1.6.0_21

Windows
Append the string ;%JAVA_HOME%\bin to the end of the system variable, Path.


Windows
Set the environment variables using system properties.
M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-2.2.1
M2=%M2_HOME%\bin
MAVEN_OPTS=-Xms256m -Xmx512m

Windows Append the string ;%M2% to the end of the system variable, Path.

C:\Users\jupiter>java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) Client VM (build 25.31-b07, mixed mode)

C:\Users\jupiter>mvn -version
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T22:10:2
7+02:00)
Maven home: C:\Downloads\apache-maven
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jdk1.8.0_31\jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "dos"

mvn archetype:generate
306
com.mytutos.maven.examples
test11

Friday, April 10, 2015

how to proxy with apache maven

Maven local settings
C:\Users\jupiter\.m2

Maven Global settings
C:\apache-maven\conf


Copy  C:\apache-maven\conf\settings into C:\Users\jupiter\.m2

Edit and add in settings.xml

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>x.x.x.x</host>
      <port>8080</port>
   </proxy>
  
  </proxies>

working with properties in pom.xml

 pom.xml file

<!-- organizing properties for grouping purposes -->
    <properties>
        <spring.security.version>3.2.0.RELEASE</spring.security.version>
    </properties>


<dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${spring.security.version}</version>
        </dependency>

how to Versions Maven Plugin

Versions Maven Plugin
The Versions Plugin is used when you want to manage the versions of artifacts in a project's POM


pom.xml, right click
Run As -> Maven build...
Goals:versions:display-plugin-updates


versions:display-plugin-updates
Displays all plugins that have newer versions available.

[INFO] Require Maven 2.0.1 to use the following plugin updates:
[INFO]   maven-war-plugin .............................................. 2.0.2
[INFO]
[INFO] Require Maven 2.0.2 to use the following plugin updates:
[INFO]   maven-site-plugin ........................................ 2.0-beta-7
[INFO]
[INFO] Require Maven 2.0.6 to use the following plugin updates:
[INFO]   maven-clean-plugin .............................................. 2.5
[INFO]   maven-deploy-plugin ........................................... 2.8.1
[INFO]   maven-install-plugin .......................................... 2.5.1
[INFO]   maven-resources-plugin .......................................... 2.6
[INFO]   maven-site-plugin ............................................. 2.0.1
[INFO]   maven-surefire-plugin ......................................... 2.4.3
[INFO]   maven-war-plugin ................................................ 2.4
[INFO]
[INFO] Require Maven 2.0.9 to use the following plugin updates:
[INFO]   maven-compiler-plugin ........................................... 3.1
[INFO]   maven-surefire-plugin .......................................... 2.17
[INFO]
[INFO] Require Maven 2.1.0 to use the following plugin updates:
[INFO]   maven-site-plugin ............................................. 2.1.1
[INFO]
[INFO] Require Maven 2.2.0 to use the following plugin updates:
[INFO]   maven-site-plugin ............................................... 3.0
[INFO]
[INFO] Require Maven 2.2.1 to use the following plugin updates:
[INFO]   maven-clean-plugin ............................................ 2.6.1
[INFO]   maven-compiler-plugin ........................................... 3.3
[INFO]   maven-deploy-plugin ........................................... 2.8.2
[INFO]   maven-install-plugin .......................................... 2.5.2
[INFO]   maven-resources-plugin .......................................... 2.7
[INFO]   maven-site-plugin ............................................... 3.4
[INFO]   maven-surefire-plugin ........................................ 2.18.1
[INFO]   maven-war-plugin ................................................ 2.6
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:11 min
[INFO] Finished at: 2015-04-10T21:01:09+02:00
[INFO] Final Memory: 9M/21M
[INFO] ------------------------------------------------------------------------


versions:display-dependency-updates
scans a project's dependencies and produces a report of those dependencies which have newer versions available.

versions:use-latest-releases
searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the latest release version.

pom.xml, right click
Run As -> Maven build
choose run options

http://mojo.codehaus.org/versions-maven-plugin/index.html

how to update apache maven

installed maven version 3.1.0
update maven version is 3.3.1
maven.apache.org

rename apache-maven.bck
C:\Downloads\apache-maven

extract apache-maven-3.3.1-bin.zip
under
C:\Downloads\apache-maven

eclipse luna configuration
Windows > Preferences > Installations > Add
Installation home :C:\Downloads\apache-maven

Tick new maven config
Apply > OK

how to define minimum maven version in pom.xml

<properties>
....
</properties>

 <prerequisites>
        <maven>2.2.1</maven>
    </prerequisites>


Sunday, March 16, 2014

my diary of resolutions

  • I run offline artifactory server which acts like maven repository.From time to time I get this error.

Eclipse Kepler Problems view tab


Description    Resource    Path    Location    Type
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.tomcat:el-api:jar:6.0.32: ArtifactResolutionException: Failure to transfer org.apache.tomcat:el-api:pom:6.0.32 from http://localhost:5555/artifactory/libs-release was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.tomcat:el-api:pom:6.0.32 from/to central (http://localhost:5555/artifactory/libs-release): Connection refused: no further information to http://localhost:5555/artifactory/libs-release/org/apache/tomcat/el-api/6.0.32/el-api-6.0.32.pom    pom.xml    /simple-parent    line 1    Maven Dependency Problem

Normally you see many errors in problems view.This is just one of them.To resolve this

right click on the project.Maven-Update Project



My guess is that if you run eclipse first when artifactory server is shut down you get this problem.


  • c3p0 problem 
This is what I get eclipse console view.

2014-03-16 22:42:10 DEBUG C3P0PooledConnectionPool:468 - Preparing to destroy PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@17c0756
2014-03-16 22:42:10 DEBUG NewPooledConnection:566 - com.mchange.v2.c3p0.impl.NewPooledConnection@17c0756 closed by a client.
java.lang.Exception: DEBUG -- CLOSE BY CLIENT STACK TRACE
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:566)
    at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
    at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
    at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:989)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$100(BasicResourcePool.java:32)
    at com.mchange.v2.resourcepool.BasicResourcePool$5.run(BasicResourcePool.java:1174)


in applicationContext.cml

<bean id="MyDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">

resolution

<bean id="MyDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >

I don't exactly know why.When I browse class path I couldn't find destroy method.



  • maven project error which is on eclipse luna

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Window > Preferences > Java > Installed JREs >Execution Environments > JavaSE-1.8
Project > Right Click > Maven > Update Project


  • ArtifactTransferException: Failure to transfer

If you get this error message starting with this you can trace the failing jar or dependency file on local folder below.This path is a generic one for hibernate

C:\Users\user1\.m2\repository\org\hibernate\hibernate-core

Remove folder or back up just in case you need.Update project via eclipse with m2eclipse

  • This happens when you configure project while artifactory is not running


C:\Users\yeniceri\.m2\repository\org\apache\maven\plugins\maven-war-plugin

Delete 2.4
Update project to sync with artifactory

  • Index downloads are disabled, search result may be incomplete.

#1
Windows > Preferences > Maven
check the box
"Download repository index updates on startup"
"Download Artifact Sources"

#2
Window > Show View > Other > Maven > Maven Repositories
central repository in 'Global Repositories'
Tick 'Full Index Enabled' and then 'Rebuild Index'

http://stackoverflow.com/questions/24252256/how-to-enable-index-downloads-in-eclipse-for-maven-search


  • -Dmaven.multiModuleProjectDirectory system property is not set.Check $M2_HOME environment variable and mvn script match.

apache-maven-3.3.1
java: 1.8.0_31
eclipse luna

Window-> Preference -> Java -> Installed JREs -> Edit
Default VM arguments
-Dmaven.multiModuleProjectDirectory=$M2_HOME

http://stackoverflow.com/questions/29330577/maven-3-3-1-eclipse-dmaven-multimoduleprojectdirectory-system-propery-is-not-s

Saturday, October 19, 2013

how to create parent pom project for organization

     Platform:
  • windows 7- 64 bit
  • java version "1.7.0_40"
  • apache-maven 3.1.0
  • eclipse Kepler 4.3.1
  • m2e - Maven Integration for Eclipse-      http://www.eclipse.org/m2e/download/
  • artifactory-3.0.3
  • tomcat7-maven-plugin
  • jetty-maven-plugin
     In this tutorial I want to create parent pom project using maven project feature.

File-New-Maven Project


select package type pom

this is how it looks like at the end

Right click on pom.xml.
Run as-Maven clean
Run as-Maven install

This is the contents of  pom.xml which is actually parent-pom file

Thursday, October 17, 2013

how to dynamic web project with maven 3


     Platform:
  • windows 7- 64 bit
  • java version "1.7.0_40"
  • apache-maven 3.1.0
  • eclipse Kepler 4.3.1
  • m2e - Maven Integration for Eclipse-      http://www.eclipse.org/m2e/download/
  • artifactory-3.0.3
  • tomcat7-maven-plugin
  • jetty-maven-plugin
  • with parent pom


In this tutorial I want to create maven-compatible eclipse dynamic web project with parent pom.

I have artifactory-3.0.3 as maven repository server running for caching artifacts.
Instead of setting up tomcat or other containers I choose  jetty-maven-plugin and tomcat7-maven-plugin.
I can't get project running on jetty embedded as I guess it might be related to windows path file problem.

create new dynamic web project






give a name and next
delete 'src' folder and create new folders as above and
change default  output folder as well




change content directory as above and tick to generate web.xml deployment descriptor
click finish



This is how it looks like after you click finish button.
It is still not maven project.

This is M2 eclipse plugin feature.Just right click on the project
Configure-Convert to Maven Project





Normally I deselect of all them as I don't need and click to finish.
This will create your pom file and maven project
 I am not sure but this must be part of M2 eclipse plugin feature
Maybe you can explain why this comes up or whether I need it or not.



Now it is maven project.

Right click on "webapp" directory then
New-Other







This is the contents of web.xml


This is the contents of pom.xml


As you are aware I use parent-pom file for my projects.There's another how-to about this parent-pom file here.



To run project on tomcat you need to create run configuration for tomcat maven plugin.
When you right click on pom.xml there are two "maven build" menu.
However the one ending with "..' is for the first time configuration.
After you create tomcat:run configuration you can use the one without "..' directly.
If you create more than one eclipse lists all run configurations.
At the bottom there's run configurations menu.

Here are the configurations for tomcat and jetty maven plugins.

works
http://localhost:8080/

don't work
http://localhost:8080/test1/index.jsp
http://localhost:8080/test1


Click to run tomcat:run window

You can start web browser that the arrow shows above.
Just the copy url painted in blue on the console.
You can stop embedded tomcat with the red open the arrow shows below

When I try to run with jetty maven plugin it fails.I even try with given whole url including index.jsp
Here is the error message on console.


Please feel free to make suggestions corrections contributions etc.All is appreciated.

References:
www.cloudchamp.com/2010/08/creating-maven-web-project-in-eclipse.html