Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Maven + Custom Type/Packaging

$
0
0

Hello,

There is something  i dont undersand with the maven plugin :

I'm working on a Maven project with custom packaging and we have a maven plugin who handle it.

 

The maven plugin plexus configuration (/META-INF/plexus/components.xml) :

 

<?xml version="1.0" encoding="UTF-8"?>
<component-set>
    <components>
        <component>
            <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
            <role-hint>the-type</role-hint>
            <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
            <configuration>
                <phases>
                    ...
                </phases>
            </configuration>
        </component>
        <component>
            <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
            <role-hint>the-type</role-hint>
            <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
            <configuration>
                <type>the-type</type>
                <extension>jar</extension>
                <language>java</language>
                <addedToClasspath>true</addedToClasspath>
            </configuration>
        </component>
        </components>
</component-set>

 

Here the declaration of the plugin in the pom project :

 

<plugin>
    <groupId>the.group.id</groupId>
    <artifactId>the.artifact.id</artifactId>
    <extensions>true</extensions>
    <executions>
        <execution>
            <goals>
                <goal>inplace</goal>
            </goals>
        </execution>
    </executions>
</plugin>

 

And for the specifics dependencies we have :

 

<dependency>
    <groupId>groudId</groupId>
    <artifactId>artifactId</artifactId>
   <version>xxx.xx.xx</version>
   <type>the-type</type>
</dependency>

 

When i import the project, the dependency with custom type are not resolved, because intellij dont know the custom type.

So i looked intothe sources of themavenplugin, and i deduced that i had to make a plugin who extends MavenImporter for handling my custom type.

 

Something like :

 

<idea-plugin version="2">
    <name>xxxx</name>
    <id>xxx</id>
    <description>
       xxx
    </description>
    <version>x.x.x</version>
    <vendor>xxx</vendor>
    <depends>org.jetbrains.idea.maven</depends>

    <extensions defaultExtensionNs="org.jetbrains">
        <idea.maven.importer implementation="custom.MyImporter"/>
    </extensions>

</idea-plugin>

 

In the MyImporter constructor, i'm passing the groupId and the artifactId of our plugin and i override the getSupportedPackagings, getSupportedDependencyTypes, isApplicable methods (like in the Android plugin).

 

When i import the project, my plugin is correctly used but intellij fail to download the artifact because it dont use the ArtifactHandler declared in the plugin.

 

On the, MavenModelConverter or Maven2ModelConverter, convertExtension method the ArtifactHandler is alway null.

ArtifactHandler handler = artifact.getArtifactHandler(); <--- is alway null

So intellij try to download artifactId.the-type and not artifactId.jar (who doesnt exist in the repository).

 

I dont know if my approach is correct or not and whatam i doing wrong .....


ps: sorry for my poor english


Viewing all articles
Browse latest Browse all 5661

Trending Articles