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

Thursday, August 23, 2012

Finding a file from a bunch of jar files

Just had a need to quickly find a file eg. the super pom location in maven which was suspected to be in one of the jar files located within Maven's lib director ($MAVEN_HOME/lib).

The following command seems to work for me, it took me some time messing around with commands to get this out, so guess it would be beneficial to put it down here just to keep myself reminded and also hopefully help some others who are googling for the same stuff.

Eg. to find the super pom located in one of the jars within Maven's lib directory we could do

find . -iname '*.jar' | xargs -n 1 jar -tvf | grep -i '**.xml'
This would gives us something like
  ...
  1523 Thu Feb 24 12:34:04 EST 2011 META-INF/maven/org.sonatype.aether/aether-api/pom.xml
  3908 Mon Feb 28 18:28:26 EST 2011 META-INF/maven/org.apache.maven/maven-embedder/pom.xml
  2222 Mon Feb 28 18:27:48 EST 2011 META-INF/maven/org.apache.maven/maven-settings-builder/pom.xml
  ...
  1931 Mon Feb 28 18:28:12 EST 2011 META-INF/maven/org.apache.maven/maven-repository-metadata/pom.xml
  2248 Mon Feb 28 18:27:52 EST 2011 META-INF/maven/org.apache.maven/maven-model-builder/pom.xml
  ...
But it doesn't tell us which jar file it's in. The simplest way I found was to
find . -iname '*.jar' | xargs --verbose -n 1 jar -tvf | grep -i '**.xml' 
jar -tvf ./aether-api-1.11.jar 
  1523 Thu Feb 24 12:34:04 EST 2011 META-INF/maven/org.sonatype.aether/aether-api/pom.xml
jar -tvf ./maven-embedder-3.0.3.jar 
  3908 Mon Feb 28 18:28:26 EST 2011 META-INF/maven/org.apache.maven/maven-embedder/pom.xml
jar -tvf ./maven-settings-builder-3.0.3.jar 
....
jar -tvf ./maven-model-builder-3.0.3.jar 
 13206 Mon Feb 28 18:30:32 EST 2011 META-INF/plexus/components.xml
  4840 Mon Feb 28 18:30:30 EST 2011 org/apache/maven/model/pom-4.0.0.xml
  2248 Mon Feb 28 18:27:52 EST 2011 META-INF/maven/org.apache.maven/maven-model-builder/pom.xml
...
Now we could tell Maven's super pom, pom-4.0.0.xml, is in maven-model-builder-3.0.3.jar file under /org/apache/maven/modem/ directory.

Friday, March 9, 2012

Ouch!! ... mvn liferay:build-service hurts ...

I've been trying to generate bunch of services using

    mvn liferay:build-service -P liferay-plugins-development
where liferay-plugins-development profile contains properties setting of my liferay version and deployment directory, and was bumped with the following exception
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.172s
[INFO] Finished at: Sat Mar 10 16:50:43 EST 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:build-service (default-cli) on project myliferay-portlet: Execution default-cli of goal com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:build-service failed: An API incompatibility was encountered while executing com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:build-service: java.lang.AbstractMethodError:
 com.liferay.util.sl4fj.LiferayLoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljav/lang/Throwable;)V
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>com.liferay.maven.plugins:liferay-maven-plugin:6.1.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/...../maven_repo/com/liferay/maven/plugins/liferay-maven-plugin/6.1.0/liferay-maven-plugin-6.1.0.jar
[ERROR] urls[1] = file:/...../maven_repo/com/liferay/portal/portal-impl/6.1.0/portal-impl-6.1.0.jar
Suspect this has something to do with different version of SLF4j that is not compatible with the one that maven resolved to when running liferay-maven-plugin, so went ahead and force the SLF4j version that the plugin was using to 1.5.5
 ...
  
    
      
         com.liferay.maven.plugins
         liferay-maven-plugin
         ${liferay.version}
         
            ${liferay.auto.deploy.dir}
            ${liferay.version}
            portlet
         
         
           
              org.slf4j
              slf4j-log4j12
              1.5.5
           
         
       
  ...
  
 ...
It seems to fix this issue, but now I'm bumped with another NullPointerException coming off liferay-maven-plugin source itself. Logged a defect with the Liferay team here (MAVEN-15). Will have to wait and see how this paints out.

Liferay-maven-plugin turns out to be quite a pain in the neck for me ... :-( Guess I should be evaluating Liferay IDE instead to see if it suits me better. It does required that the whole plugins project to be under a Liferay-Plugin-SDK directory though.

Monday, March 5, 2012

Liferay's Maven Archetypes

Been googling a bit for Liferay maven archetypes available, well typically for 6.1.0 as pre 6.1.0 does not have any maven archetypes in public repositories, and they aren't just listed in one web page. Putting them all down here in one place just so it's easier for whoever that's googling for this piece of information. This is the official Liferay blog that list down all the possible Liferay Maven archetypes, which are :-

  • liferay-ext-archetype
  • liferay-hook-archetype
  • liferay-layouttpl-archetype
  • liferay-portlet-archetype
  • liferay-theme-archetype
  • liferay-web-archetype
with the following properties
 liferay.version
 liferay.auto.deploy.dir
through my profile settings in ~/.m2/settings.xml

  ...
  
    ...
    
       liferay-plugins-development
       
          ...
          ...
       
    
    ...
  
  ...

with the mvn command to invoke them as follows
mvn archetype:generate 
         -DarchetypeArtifactId=liferay-portlet-archetype 
         -DarchetypeGroupId=com.liferay.maven.archetypes 
         -DarchetypeVersion=6.1.0 
         -DarchetypeCatalog=local,remote 
         -DartifactId=sample-portlet 
         -DgroupId=com.liferay.sample 
         -Dversion=1.0-SNAPSHOT
and the following mvn command just to install the whatever resultant artifacts using the 'liferay-plugins-development' profile
mvn install -P liferay-plugins-development

Sunday, December 4, 2011

mvn eclipse:eclipse failed to work

I found that

  mvn eclipse:eclipse
do not really work well when you've got multiple modules in your maven structure like PlayN, spitting out the following error
   Failed to execute goal org.apache.maven.plugins:maven-eclipse-plugin:2.8:eclipse (default-cli) on project playn-archetype 
Request to merge when 'filtering' is not identical. 
After some digging and trying out, it seems that specifying a specific version of maven-eclipse-plugin seems to make it happy, guessing maven gets confused when trying to resolve which maven-eclipse-plugin to use in the process. Anyway here's the one that works for me

   org.apache.maven.plugins
   maven-eclipse-plugin
   2.6