Skip to content

Naming of result file for multiple building

Igor Maznitsa edited this page Oct 6, 2016 · 2 revisions

For instance you want to make cross-compilation of your project and public each compiled binary file under its own unique name. In the case you can use below profile (I use it very often, for instance in zx-to-wav project).

<profile>
  <id>publish</id>
  <build>
    <plugins>
      <plugin>
        <groupId>com.igormaznitsa</groupId>
        <artifactId>mvn-golang-wrapper</artifactId>
        <version>${mvngolang.version}</version>
        <executions>
          <!-- This execution will block default build process -->
          <execution>
            <id>default-build</id>
            <phase>none</phase>
          </execution>
          <!-- This execution will build version for linux amd64 -->   
          <execution>
           <id>build-for-linux64</id>
           <goals>
             <goal>build</goal>
           </goals>
           <configuration>
             <targetOs>linux</targetOs>
             <targetArch>amd64</targetArch>
             <resultName>${base.target.name}-linux-amd64</resultName>
             <packages>
               <app>main.go</app>
             </packages>
           </configuration>
         </execution>
         <!-- This execution will build version for linux i386 -->  
         <execution>
           <id>build-for-linux386</id>
           <goals>
             <goal>build</goal>
           </goals>
           <configuration>
             <targetOs>linux</targetOs>
             <targetArch>386</targetArch>
             <resultName>${base.target.name}-linux-386</resultName>
             <packages>
               <app>main.go</app>
             </packages>
           </configuration>
         </execution>
         <!-- This execution will build version for windows i386 -->  
         <execution>
           <id>build-for-windows386</id>
           <goals>
             <goal>build</goal>
           </goals>
           <configuration>
            <targetOs>windows</targetOs>
            <targetArch>386</targetArch>
            <resultName>${base.target.name}-windows-386.exe</resultName>
             <packages>
               <app>main.go</app>
             </packages>
           </configuration>
         </execution>
       </executions>
     </plugin>
   </plugins>
 </build>
</profile>