0

I would like to add a source jar to a gwt project using maven.

I tried to do it this way (it's just a poc for managing source dependencies)

source jar pom :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
    <artifactId>test-source-dependencies</artifactId>
    <groupId>com.niflheimcorp</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-source-jar</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jar-no-fork</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

</build>
</project>

using jar pom :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.niflheimcorp</groupId>
<artifactId>test-utilisateur-jar</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

 <dependencies>
    <dependency>
        <groupId>com.niflheimcorp</groupId>
        <artifactId>test-source-jar</artifactId>
        <classifier>source</classifier>
    </dependency>
</dependencies> 
</project>

when launching mvn clean install i got the following error :

[ERROR] Failed to execute goal on project test-utilisateur-jar: Could not resolv
e dependencies for project com.niflheimcorp:test-utilisateur-jar:jar:1.0-SNAPSHO
T: Could not find artifact com.niflheimcorp:test-source-jar:jar:source:1.0-SNAPS
HOT -> [Help 1]

But the artifact is installed by maven just at the precedent step

[INFO] Installing C:\Users\CRSD2193\psf\G4R0C3_portaFixe\test-sources-dependenci

es\test-source-jar\target\test-source-jar-1.0-sources.jar to C:\Users\CRSD2193. m2\repository\com\niflheimcorp\test-source-jar\1.0\test-source-jar-1.0-sources.j ar

I can't see a reason for the error unless we can't declare a source jar as a build deps.

Regards

Nemesis

Nemesis
  • 2,750
  • 2
  • 22
  • 20
  • 1
    Why do you want to do this? –  Oct 29 '14 at 10:04
  • First of all, sources as dependency seems weird. Next, the classifier is called `sources` not `source`. – lexicore Oct 29 '14 at 10:10
  • Classifier should be `sources`, with an `s`. – Joe Oct 29 '14 at 10:10
  • well i want to do this because gwt needs sources to compile and i hate copiing sources in the project webapp (code duplication + weird exclusion for compile and sonar analyze) so in this context source jar as dependency is not as weird as it seems to be. And thank you to point me to my mistake effectively i made a typo on the classifier and didn't notices it :-/ – Nemesis Oct 29 '14 at 10:19

1 Answers1

0

Dumb typo on the classifier sources (forgot the s at the end :-/ ).

Nemesis
  • 2,750
  • 2
  • 22
  • 20