David Williams David Williams - 6 months ago 13
Java Question

How to Use ASM Library in Maven Project

I am trying to use the ASM byte code engineering library in a maven project. I put this in my pom

<dependency>
<groupId>asm</groupId>
<artifactId>asm-parent</artifactId>
<version>3.3.1</version>
</dependency>


But my code fails to build, because no jar is present. When I examine the contents of .m2 I see

ll ~/.m2/repository/asm/asm-parent/3.3.1/
total 40
drwxr-xr-x 6 david staff 204 Oct 25 08:25 .
drwxr-xr-x 5 david staff 170 Dec 24 2013 ..
-rw-r--r-- 1 david staff 156 Dec 18 2013 _maven.repositories
-rw-r--r-- 1 david staff 242 Oct 25 08:25 asm-parent-3.3.1.jar.lastUpdated
-rw-r--r-- 1 david staff 4332 Dec 18 2013 asm-parent-3.3.1.pom
-rw-r--r-- 1 david staff 40 Dec 18 2013 asm-parent-3.3.1.pom.sha1


And this:

[ERROR] Failed to execute goal on project asm-test:
Could not resolve dependencies for project com.example:asm-test:jar:1.0-SNAPSHOT:
Could not find artifact asm:asm-parent:jar:3.3.1 in central
(http://repo.maven.apache.org/maven2),
try downloading from http://mojo.codehaus.org/my-project -> [Help 1]

Answer

asm-parent dependencey type is pom, try below

        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-parent</artifactId>
            <version>3.3.1</version>
            <type>pom</type>
        </dependency>

if you want to use asm only

<dependency>
    <groupId>asm</groupId>
    <artifactId>asm</artifactId>
    <version>3.3.1</version>
</dependency>
Comments