Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Making symbolic link named ".m2" to Gradle JAR repo

After many years of using Maven, I am used to that my JARs are in ~/.m2/ directory, so I created myself a link as follows:


$ ln -s ~/.gradle/caches/modules-2/files-2.1 ~/.m2 

$ ls -alt ~/.m2/
total 0
drwxr-xr-x  65 ukilucas  staff  2210 Apr 28 23:18 .
drwxr-xr-x   3 ukilucas  staff   102 Apr 28 23:18 junit
drwxr-xr-x   4 ukilucas  staff   136 Apr 28 23:18 org.hamcrest
drwxr-xr-x   3 ukilucas  staff   102 Apr 28 14:15 com.android.tools.external.lombok
drwxr-xr-x   3 ukilucas  staff   102 Apr 28 14:15 org.abego.treelayout

drwxr-xr-x   3 ukilucas  staff   102 Apr 28 14:15 com.intellij
..


As an Amazon Associate I earn from qualifying purchases.

Making symbolic link named ".m2" to Gradle JAR repo

After many years of using Maven, I am used to that my JARs are in ~/.m2/ directory, so I created myself a link as follows:


$ ln -s ~/.gradle/caches/modules-2/files-2.1 ~/.m2 

$ ls -alt ~/.m2/
total 0
drwxr-xr-x  65 ukilucas  staff  2210 Apr 28 23:18 .
drwxr-xr-x   3 ukilucas  staff   102 Apr 28 23:18 junit
drwxr-xr-x   4 ukilucas  staff   136 Apr 28 23:18 org.hamcrest
drwxr-xr-x   3 ukilucas  staff   102 Apr 28 14:15 com.android.tools.external.lombok
drwxr-xr-x   3 ukilucas  staff   102 Apr 28 14:15 org.abego.treelayout

drwxr-xr-x   3 ukilucas  staff   102 Apr 28 14:15 com.intellij
..


As an Amazon Associate I earn from qualifying purchases.

Maven: executing JAR created with Maven

In this tutorial we will learn how to create an executable jar with Maven and run it from command line.


Let's add a maven-jar-plugin to your pom, make sure you specify your main class as such:

<mainClass>exec.MyApp</mainClass>





Run Maven:

uki@ JavaFxSceneSwitch $ mvn clean install[INFO] Scanning for projects...[INFO]                                                                         [INFO] ------------------------------------------------------------------------[INFO] Building JavaFxSceneSwitch 1.0-SNAPSHOT[INFO] ------------------------------------------------------------------------...[INFO] Installing .. to /Users/uki/.m2/repository/edu/clcillinois/cit137/JavaFxSceneSwitch/1.0-SNAPSHOT/JavaFxSceneSwitch-1.0-SNAPSHOT.jar[INFO] Installing ...[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.822 s[INFO] Finished at: 2015-04-21T14:57:43-05:00[INFO] Final Memory: 15M/91M[INFO] ------------------------------------------------------------------------



Run the app from the ROOT of your project:


uki@ UKI_LUCAS $ java -jar  /Users/uki/.m2/repository/edu/clcillinois/cit137/JavaFxSceneSwitch/1.0-SNAPSHOT/JavaFxSceneSwitch-1.0-SNAPSHOT.jar



The JavaFX app should start, if you start it from other folder, observe how the Image path behaves.



As an Amazon Associate I earn from qualifying purchases.

Maven: executing JAR created with Maven

In this tutorial we will learn how to create an executable jar with Maven and run it from command line.


Let's add a maven-jar-plugin to your pom, make sure you specify your main class as such:

<mainClass>exec.MyApp</mainClass>





Run Maven:

uki@ JavaFxSceneSwitch $ mvn clean install[INFO] Scanning for projects...[INFO]                                                                         [INFO] ------------------------------------------------------------------------[INFO] Building JavaFxSceneSwitch 1.0-SNAPSHOT[INFO] ------------------------------------------------------------------------...[INFO] Installing .. to /Users/uki/.m2/repository/edu/clcillinois/cit137/JavaFxSceneSwitch/1.0-SNAPSHOT/JavaFxSceneSwitch-1.0-SNAPSHOT.jar[INFO] Installing ...[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 1.822 s[INFO] Finished at: 2015-04-21T14:57:43-05:00[INFO] Final Memory: 15M/91M[INFO] ------------------------------------------------------------------------



Run the app from the ROOT of your project:


uki@ UKI_LUCAS $ java -jar  /Users/uki/.m2/repository/edu/clcillinois/cit137/JavaFxSceneSwitch/1.0-SNAPSHOT/JavaFxSceneSwitch-1.0-SNAPSHOT.jar



The JavaFX app should start, if you start it from other folder, observe how the Image path behaves.



As an Amazon Associate I earn from qualifying purchases.

Java: find jar

When you are looking for a given Java class, you can use this online database to locate jars:

Example, looking for log4j

http://www.findjar.com/index.x?query=log4j

Among others I get response:

[JAR] log4j-1.1.3.jar in log4j/log4j/1.1.3
[JAR] log4j-1.2.11.jar in log4j/log4j/1.2.11
[JAR] log4j-1.2.12.jar in log4j/log4j/1.2.12





As an Amazon Associate I earn from qualifying purchases.

Java: find jar

When you are looking for a given Java class, you can use this online database to locate jars:

Example, looking for log4j

http://www.findjar.com/index.x?query=log4j

Among others I get response:

[JAR] log4j-1.1.3.jar in log4j/log4j/1.1.3
[JAR] log4j-1.2.11.jar in log4j/log4j/1.2.11
[JAR] log4j-1.2.12.jar in log4j/log4j/1.2.12





As an Amazon Associate I earn from qualifying purchases.

Maven: installing apk, or arr, or jar in .m2

Sometimes you get a built artifact (apk, arr, jar) and instead of keeping it in your Downloads, or com up with a nice folder structure, you can simply put it in your Maven .m2 repository, that what it is designed for.


$ mvn install:install-file -Dpackaging=apk -DgroupId=com. mycompany.android -DartifactId= SomeApp -Dversion=1.4.42.0 -Dfile=/Users/uki/Downloads/SomeApp-1.4.42.0.apk

[INFO] Scanning for projects...

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Stub Project (No POM) 1

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---

[INFO] Installing /Users/uki/Downloads/SomeApp-1.4.42.0.apk to /Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.apk

[INFO] Installing .../Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------



As an Amazon Associate I earn from qualifying purchases.

Maven: installing apk, or arr, or jar in .m2

Sometimes you get a built artifact (apk, arr, jar) and instead of keeping it in your Downloads, or com up with a nice folder structure, you can simply put it in your Maven .m2 repository, that what it is designed for.


$ mvn install:install-file -Dpackaging=apk -DgroupId=com. mycompany.android -DartifactId= SomeApp -Dversion=1.4.42.0 -Dfile=/Users/uki/Downloads/SomeApp-1.4.42.0.apk

[INFO] Scanning for projects...

[INFO]                                                                         

[INFO] ------------------------------------------------------------------------

[INFO] Building Maven Stub Project (No POM) 1

[INFO] ------------------------------------------------------------------------

[INFO] 

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---

[INFO] Installing /Users/uki/Downloads/SomeApp-1.4.42.0.apk to /Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.apk

[INFO] Installing .../Users/uki/.m2/repository/com/mycompany/android/SomeApp/1.4.42.0/SomeApp-1.4.42.0.pom

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------



As an Amazon Associate I earn from qualifying purchases.

android-maven-plugin-4.0

As you are migrating your projects from old to new Android structure you may encounter:



As an Amazon Associate I earn from qualifying purchases.

android-maven-plugin-4.0

As you are migrating your projects from old to new Android structure you may encounter:




[ERROR] Found files or folders in non-standard locations in the project! [ERROR] ....This might be a side-effect of a migration to Android Maven Plugin 4+.

android-maven-plugin-4.0 uses the new Android Studio folder layout which is much more Mavenish.

  • Android resources should be is src\main\res, 
  • Android assets in src\main\assets, 
  • AndroidManifest.xml in src\main


As an Amazon Associate I earn from qualifying purchases.

Maven: updating version on Mac

In this tutorial we will discuss upgrading Maven on Mac OS X.



As an Amazon Associate I earn from qualifying purchases.

Maven: updating version on Mac

In this tutorial we will discuss upgrading Maven on Mac OS X.




While trying building with Maven I was getting errors related to version number (below 3.1) 

mvn install
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

To update my maven I have to do the following sequence of steps.

$ mvn -version

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 07:51:28-0600)


I had to uninstall the older version 3.0

$ brew uninstall maven30

Uninstalling /usr/local/Cellar/maven30/3.0.5...


Trying to install newest I noticed that I tried it before, but it was not linked

$ brew install maven

Warning: maven-3.2.3 already installed, it's just not linked


The easiest way to fix that is to uninstall and install again:

$ brew uninstall maven

Uninstalling /usr/local/Cellar/maven/3.2.3...
$ brew install maven

==> Downloading http://www.apache.org/dyn/closer.cgi?path=maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gzAlready downloaded: /Library/Caches/Homebrew/maven-3.2.3.tar.gz
🍺  /usr/local/Cellar/maven/3.2.3: 76 files, 8.0M, built in 3 seconds
uki@ CNH_PROD $ mvn -version
Apache Maven 3.2.3



As an Amazon Associate I earn from qualifying purchases.

Maven: installing Android SDK

In order to compile Android project using Maven you have to instal Android SDK to your Maven repository.


$ git clone https://github.com/mosabua/maven-android-sdk-deployer.git
Cloning into 'maven-android-sdk-deployer'...
remote: Counting objects: 3198, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 3198 (delta 3), reused 6 (delta 3)
Receiving objects: 100% (3198/3198), 435.92 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1585/1585), done.
Checking connectivity... done.

$ cd maven-android-sdk-deployer/


As an Amazon Associate I earn from qualifying purchases.

Maven: installing Android SDK

In order to compile Android project using Maven you have to instal Android SDK to your Maven repository.


$ git clone https://github.com/mosabua/maven-android-sdk-deployer.git
Cloning into 'maven-android-sdk-deployer'...
remote: Counting objects: 3198, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 3198 (delta 3), reused 6 (delta 3)
Receiving objects: 100% (3198/3198), 435.92 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1585/1585), done.
Checking connectivity... done.

$ cd maven-android-sdk-deployer/


As an Amazon Associate I earn from qualifying purchases.

Installing Maven

After few years of not needing it, I came back to Maven, reason being that I cannot use Gradle for reasons beyond my control and Ant does not describe complex projects structures required.


As an Amazon Associate I earn from qualifying purchases.

Installing Maven

After few years of not needing it, I came back to Maven, reason being that I cannot use Gradle for reasons beyond my control and Ant does not describe complex projects structures required.


Getting new version of Maven


$ brew install maven
==> Downloading ....
/usr/local/Cellar/maven/3.2.3:
$ mvn -version

Apache Maven 3.2.3
$ which mvn
/usr/local/bin/mvn


Setting M2_HOME


$ echo $M2_HOME
# nada


I added the following in my ~/.profile




# Maven - updated: Oct 20, 2014
export MAVEN_HOME=/usr/local/Cellar/maven/3.2.3/
export PATH=${PATH}:${MAVEN_HOME}/bin
export M2_HOME=/usr/local/Cellar/maven/3.2.3/
export PATH=${PATH}:${M2_HOME}/libexec


and run:

$ echo $M2_HOME
/usr/local/Cellar/maven/3.2.3/



As an Amazon Associate I earn from qualifying purchases.

Eclipse 3.5 installation with GWT 2.0 RC1

1. Install Eclipse 3.5 (Galileo Eclipse IDE for JAVA EE Developers): http://www.eclipse.org/downloads/ Extract Eclipse package in Application directory (on your Mac).


2. Download latest Eclipse 3.5 plugin for GWT http://dl.google.com/eclipse/plugin/3.5/zips/gpe-e35-latest.zip Extract the archive into the dropins directory in your Eclipse installation. Your installation of Eclipse will now have a directory dropins/eclipse/features/com.google.gdt.eclipse.suite.e35.feature_version and some newly installed JAR files in dropins/eclipse/plugins/
Restart Eclipse. The plugin should now be installed!


3. In eclipse, Install SubEclipse (SVN):
Click on Help menu -> Install New Software -> paste http://subclipse.tigris.org/update_1.6.x and click add button


Select all options and click next
Click Finish and you will be asked to restart your Eclipse 


4. Install Maven, if you are using Maven to manage dependancies in your project
Click on Help menu -> Install New Software -> paste http://m2eclipse.sonatype.org/update/http://m2eclipse.sonatype.org/update/ and click add button




Select all options and click next
Click Finish and you will be asked to restart your Eclipse 





As an Amazon Associate I earn from qualifying purchases.

Eclipse 3.5 installation with GWT 2.0 RC1

1. Install Eclipse 3.5 (Galileo Eclipse IDE for JAVA EE Developers): http://www.eclipse.org/downloads/ Extract Eclipse package in Application directory (on your Mac).


2. Download latest Eclipse 3.5 plugin for GWT http://dl.google.com/eclipse/plugin/3.5/zips/gpe-e35-latest.zip Extract the archive into the dropins directory in your Eclipse installation. Your installation of Eclipse will now have a directory dropins/eclipse/features/com.google.gdt.eclipse.suite.e35.feature_version and some newly installed JAR files in dropins/eclipse/plugins/
Restart Eclipse. The plugin should now be installed!


3. In eclipse, Install SubEclipse (SVN):
Click on Help menu -> Install New Software -> paste http://subclipse.tigris.org/update_1.6.x and click add button


Select all options and click next
Click Finish and you will be asked to restart your Eclipse 


4. Install Maven, if you are using Maven to manage dependancies in your project
Click on Help menu -> Install New Software -> paste http://m2eclipse.sonatype.org/update/http://m2eclipse.sonatype.org/update/ and click add button




Select all options and click next
Click Finish and you will be asked to restart your Eclipse 





As an Amazon Associate I earn from qualifying purchases.

Installing GWT 1.7 with Maven2



Change pom.xml:

<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>1.7.0</version>
</dependency>

RUN Maven2 (via Ant) to see missing dependencies:



<property name="GOOGLE_WAR" value=".\\war" />
<property name="MAVEN_TARGET" value=".\\target" />
<property name="GOOGLE_SRC" value=".\\src" />
<property file=".\\maven\\resources\\${user.name}.properties" />


<target name="prepare">
<echo>Make sure you have set up Maven Executable in .\\maven\\resources\\${user.name}.properties</echo>
<echo>Your mvn exe is set to ${MAVEN_EXEC}</echo>
<!-- resources:resources filters the files in the resources directory and copies them to target/classes -->
<!-- dependency:copy-dependencies copies the dependencies to the target/dependency folder -->
<exec taskname="mvn war" dir="${basedir}"
executable="${MAVEN_EXEC}">
<arg line="clean resources:resources dependency:copy-dependencies -Dtarget=${TARGET}" />
</exec>
<delete dir="${GOOGLE_WAR}\\WEB-INF\\lib" />
<!-- copy the maven depenecies to the war/WEB-INF/lib folder -->
<copy todir="${GOOGLE_WAR}\\WEB-INF\\lib">
<fileset dir="${MAVEN_TARGET}\\dependency" />
</copy>
<!-- copy the filtered resources to the src folder -->
<copy todir="${GOOGLE_SRC}">
<fileset dir="${MAVEN_TARGET}\\classes" />
</copy>
</target>





Install missing dependencies to your LOCAL REPO:

uki@Uki:~ $ cd /opt/gwt/gwt-mac-1.7.0
uki@Uki:/opt/gwt/gwt-mac-1.7.0 $ mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-servlet -Dversion=1.7.0 -Dpackaging=jar -Dfile=gwt-servlet.jar [INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /opt/gwt/gwt-mac-1.7.0/gwt-servlet.jar to /Users/uki/.m2/repository/com/google/gwt/gwt-servlet/1.7.0/gwt-servlet-1.7.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
uki@Uki:/opt/gwt/gwt-mac-1.7.0 $ mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-user -Dversion=1.7.0 -Dpackaging=jar -Dfile=gwt-user.jar
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install:install-file] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /opt/gwt/gwt-mac-1.7.0/gwt-user.jar to /Users/uki/.m2/repository/com/google/gwt/gwt-user/1.7.0/gwt-user-1.7.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL


RE-run the Ant (Maven2) until you get BUILD SUCCESSFUL


















As an Amazon Associate I earn from qualifying purchases.

apt quotation..