开发者

appassembler and long classpath

开发者 https://www.devze.com 2022-12-24 01:57 出处:网络
I am using maven appassembler to create my assembly. My classpath is too long and I get \"The input line is too long.\"The suggestion here is to use开发者_如何学运维 booter windows platform, but I\'m

I am using maven appassembler to create my assembly. My classpath is too long and I get "The input line is too long." The suggestion here is to use开发者_如何学运维 booter windows platform, but I'm constrained to use Java Service Wrapper. Any way I can use java6 wildcarded classpath and java service wrapper?


Have you tried:

<useWildcardClassPath>true</useWildcardClassPath>

This solved the problem for me, however, if you arent already, you also need to make sure you are using:

<repositoryLayout>flat</repositoryLayout>


It seems that the answer is 'No', without writing a plugin or extending the existing plugin, which is not an 'answer' to the original question.


I'd suggest filing a bug in http://jira.codehaus.org/browse/MAPPASM to address it. I wrote the JSW integration and know it needs a bit more work.


You can also try flattening the directory structure of the repository (i.e. lib) directory. By default, the appassembler preserves the deep directory structure which can add unnecessary length to the classpath.

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>appassembler-maven-plugin</artifactId>
      <version>1.3.1</version>
      <configuration>
        <programs>
          <program>
            <mainClass>com.mycompany.app.MyApp</mainClass>
            <name>runMyApp</name>
          </program>
        </programs>
        <repositoryLayout>flat</repositoryLayout>
      </configuration>
    </plugin>
  </plugins>
</build>


On the windows command prompt the maximum length of the string that you can use at the command prompt is 8191 characters.

So if your project has too many dependencies, then it will generate long classpath.

To overcome this situation maven-appassembler has provided option

Add these two lines under configuration section

<configuration>
    <repositoryLayout>flat</repositoryLayout>
    <useWildcardClassPath>true</useWildcardClassPath>
</configuration>

Documentation for these two options : (documentation)

useWildcardClassPath:

Sometimes it happens that you have many dependencies which means having a very long classpath, and becomes too long (in particular on Windows based platforms). This option can help in such situation. If you activate this option, your classpath contains only a classpath wildcard (REPO/*). But be aware that this works only in combination with Java 1.6 and above and with repositoryLayout flat.

repositoryLayout:

The layout of the generated Maven repository. Supported types - "default" (Maven2) | "legacy" (Maven1) | "flat" (flat lib/ style). The style "legacy" is only supported if you are running under Maven 2.2.1 and before.


As a long shot...

Having never worked with JSW, perhaps you could create your own assembly plugin based on the code at http://maven.apache.org/plugins/maven-assembly-plugin/source-repository.html and use it instead.


I have filed a JIRA issue here:

http://jira.codehaus.org/browse/MAPPASM-203

You can go and vote for it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号