lgrignon/jsweet-maven-plugin

Plugin properties inheritance

Closed this issue · 4 comments

It has been reported on the JSweet forum that the plugin properties are not inherited in child poms. This is strange because normally plugin properties are supposed to be inherited (from the Maven doc). It would be worth checking that JSweet configuration is inherited from the parent pom because it could be helpful. Thanks!

It worked for me (starting from the simple-parent example project https://github.com/sonatype/maven-example-en/tree/master/examples/ch-optimize)

parent 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
  	<groupId>org.sonatype.mavenbook.optimize</groupId>
  	<artifactId>parent</artifactId>
  	<version>0.8-SNAPSHOT</version>
  </parent>
  <artifactId>simple-parent</artifactId>
  <packaging>pom</packaging>
  <name>Optimization Chapter Simple Parent Project</name>
   <modules>
     ...
    <module>simple-jsweet</module>
  </modules>
  <build>
    <pluginManagement>
      <plugins>
        ...
        <plugin>
            <groupId>org.jsweet</groupId>
            <artifactId>jsweet-maven-plugin</artifactId>
            <version>2.0.0-SNAPSHOT</version>
            <configuration>
                <bundle>true</bundle>
                <outDir>${project.basedir}/src/main/resources/META-INF/resources/webjars/${project.artifactId}/${project.version}</tsOut>
                <dtsOut>${project.basedir}/src/main/resources/META-INF/resources/typings/${project.artifactId}/${project.version}</dtsOut>
                <tsOut>${project.basedir}/target/tsout</tsOut>
                <declaration>true</declaration>
                <targetVersion>ES3</targetVersion>
                <module>commonjs</module>
                <verbose>true</verbose>
            </configuration>
            <executions>
                <execution>
                    <id>generate-js</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>jsweet</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

      </plugins>
   </pluginManagement> 
  </build>

And in the child project's 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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.sonatype.mavenbook.optimize</groupId>
    <artifactId>simple-parent</artifactId>
    <version>0.8-SNAPSHOT</version>
  </parent>
  <artifactId>simple-jsweet</artifactId>
  <packaging>jar</packaging>

  <name>Optimization Chapter Simple JSweet</name>

  <dependencies>
  </dependencies>

  <build>
    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
        <plugins>
          <plugin>
            <groupId>org.jsweet</groupId>
            <artifactId>jsweet-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
</project>

I think it matters to only specify groupId and artifactId in child project's pom

I found my problem, the path parameters are most of the time always relative.
My configuration contained : <outDir>/src and not <outDir>${project.basedir}/src
I believe it should be relative by default.

Actually it is relative by default, but is not anymore if there is a leading '/' like in your case <outDir>/src
I think you can just use <outDir>src and you should be just fine.

Thanks for your help