Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for a completely flat appassembler output #105

Open
tonyganchev opened this issue Jun 15, 2020 · 1 comment
Open

Allow for a completely flat appassembler output #105

tonyganchev opened this issue Jun 15, 2020 · 1 comment

Comments

@tonyganchev
Copy link

tonyganchev commented Jun 15, 2020

Our product today consists of just a single executable jar-with-dependencies.
We want to have appassembler generate a startup batch and shell script but we cannot afford for backward compatibility reasons to follow the standard appassembler directory layout. What we need is a simple flat structure containing both the jar and the startup scripts.

I tried to make such a layout work with appassembler to no avail. The generated batch script always looks for the parent directory of the script and then looks for a nested directory $repositoryName}.

Are we missing something?

We've been testing with 1.10 and 2.1.0 versions of appassembler.

Our pom.xml:

<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.example.the</groupId>
   <artifactId>app</artifactId>

   <properties>
      <main.class>com.example.path.to.the.App</main.class>
      <product.name>the-app</product.name>
      <repo.name>.</repo.name>
   </properties>

   <dependencies>
      ...
   </dependencies>

   <build>
      <plugins>
         <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
               <archive>
                  <manifest>
                     <mainClass>${main.class}</mainClass>
                  </manifest>
               </archive>
               <descriptorRefs>
                  <descriptorRef>jar-with-dependencies</descriptorRef>
               </descriptorRefs>
               <finalName>${product.name}</finalName>
               <outputDirectory>${project.build.directory}/${repo.name}</outputDirectory>
            </configuration>
            <executions>
               <execution>
                  <id>assembly</id>
                  <phase>package</phase>
                  <goals>
                     <goal>single</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <configuration>
               <mainClass>${main.class}</mainClass>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <configuration>
               <repositoryName>${repo.name}</repositoryName>
               <binFolder>.</binFolder>
               <repositoryLayout>flat</repositoryLayout>
               <assembleDirectory>${project.build.directory}</assembleDirectory>
               <binFileExtensions>
                  <unix>.sh</unix>
               </binFileExtensions>
               <programs>
                  <program>
                     <id>${product.name}</id>
                     <mainClass>${main.class}</mainClass>
                  </program>
               </programs><includeConfigurationDirectoryInClasspath>false</includeConfigurationDirectoryInClasspath>
               <generateRepository>false</generateRepository>
               <useWildcardClassPath>true</useWildcardClassPath>
            </configuration>
            <executions>
               <execution>
                  <id>assemble</id>
                  <phase>package</phase>
                  <goals>
                     <goal>assemble</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</project>
@giflw
Copy link

giflw commented Mar 24, 2022

You can try use custom scripts. Just look at scripts used by appassembler, copy them to your project and customize.

You can point to those new script in configuration session:

<unixScriptTemplate>${basedir}/src/main/appassembler/unixBinTemplate.sh</unixScriptTemplate>
<windowsScriptTemplate>${basedir}/src/main/appassembler/windowsBinTemplate.bat</windowsScriptTemplate>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants