flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

Sample configuration for multiple operating systems.

Open groldan opened this issue 4 years ago • 0 comments

Here's a configuration that works for linux, windows, and osx. Mabe you want to include it in the readme.

I've seen issue #5 but it won't handle the classifier and the distribution correctly.

<properties>
    <fbs.sources>${project.basedir}/src/main/resources/fbs</fbs.sources>
    <fbs.generated.sources>${project.build.directory}/generated-sources/java</fbs.generated.sources>
    <fbs.executable>${project.build.directory}/bin/flatc</fbs.executable>
    <fbs.executable.package.type>tar.gz</fbs.executable.package.type>
    <fbs.executable.package.distribution>distribution-linux</fbs.executable.package.distribution>
  </properties>

  <profiles>
    <profile>
      <id>platform-windows</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <fbs.executable>${project.build.directory}/bin/flatc.exe</fbs.executable>
        <fbs.executable.package.type>zip</fbs.executable.package.type>
        <fbs.executable.package.distribution>distribution-windows</fbs.executable.package.distribution>
      </properties>
    </profile>
    <profile>
      <id>platform-osx</id>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <properties>
        <fbs.executable.package.distribution>distribution-osx</fbs.executable.package.distribution>
      </properties>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>geogig.flatbuffers</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.github.davidmoten</groupId>
                  <artifactId>flatbuffers-compiler</artifactId>
                  <version>${flatbuffers-compiler.version}</version>
                  <type>${fbs.executable.package.type}</type>
                  <classifier>${fbs.executable.package.distribution}</classifier>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!-- See https://github.com/davidmoten/flatbuffers -->
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>generate-sources</phase>
          </execution>
        </executions>
        <configuration>
          <executable>${fbs.executable}</executable>
          <workingDirectory>${fbs.sources}</workingDirectory>
          <arguments>
            <argument>--java</argument>
            <argument>--gen-mutable</argument>
            <argument>-o</argument>
            <argument>${fbs.generated.sources}</argument>
            <argument>Value.fbs</argument>
            <argument>RevisionObject.fbs</argument>
          </arguments>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${fbs.generated.sources}</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

groldan avatar Jun 13 '20 16:06 groldan