0

Looked at and followed : Ant - how to get all files' name in a specific folder

But I see jar names are either truncated or jumbled incorrectly in MANIFEST.MF file.

Is there a way to fix it?

Here is excerpt of Ant target where I am seeing issue using manifestclasspath or with pathconvert approach..

       <manifestclasspath property="jar.classpath" jarfile="${dist.dir}/Cling.ear">
          <classpath>
            <fileset dir="${dist.dir}/lib" includes="*.jar"/>
          </classpath>
        </manifestclasspath>

      <echo message="${jar.classpath}"/>

      <ear destfile="${dist.dir}/Cling.ear" appxml="${app.home}/WebContent/META-INF/application.xml" manifestencoding="UTF-8">
         <fileset dir="${dist.dir}" includes="**" />
         <manifest>
           <attribute name="Implementation-Vendor" value="Some Company" />
           <attribute name="encoding" value="UTF-8" />
           <attribute name="Class-Path" value="${jar.classpath}" />
         </manifest>
     </ear>

Excerpt of that created section looks like below, where you can notice 2 jar names are truncated by some line size or some means & is continued on next line - which results in class not found exception when application is run..

Class-Path: lib/abcd-efg-1.2.11.jar lib/zzz.jar *lib/abc.def.gh.ijk.l mno_8.5.0.jar* lib/com.abc.de.fig_8.5.0.jar *lib/com.blah.zz 2.some.jar*

vinWin
  • 509
  • 1
  • 5
  • 18
  • And I don't see any problem when I print & see output of converted property, were space is correctly present & no jar names are broken into pieces.. `` – vinWin Dec 18 '19 at 17:43
  • Hope we can use `manifest` task even for creating Ear?. Official doc shows example on jar creation. .. – vinWin Dec 19 '19 at 09:43
  • See https://stackoverflow.com/questions/33758244/add-classpath-in-manifest-file-of-jar-in-gradle-in-java-8?rq=1 – martin clayton Dec 19 '19 at 11:34
  • Thanks @martinclayton for the pointer. So you are referring to go with _custom_ ant task to achieve it, as question in above post refer to Gradle? – vinWin Dec 19 '19 at 11:50
  • No - I think you could just insert newlines before each space in the classpath so that each filename is on its own line, prefixed by a space. (Sorry for the confusing link...) – martin clayton Dec 19 '19 at 14:25
  • As classpath is framed here using fileset includes/** and same is supplied to `manifestclasspath` I am not seeing that as direct option. As an alternative tried with `pathconvert` - no luck either – vinWin Dec 19 '19 at 18:24
  • Here is excerpt of framing that using `pathconvert` ` ` – vinWin Dec 19 '19 at 18:25
  • They're not truncated or jumbled; they're just newlined. This is how jar manifests are formatted. Fix whatever code is choking on the standard manifest format. – CAustin Dec 20 '19 at 00:08
  • Actually it's not, with generated Manifest file in that format it results in 'Could not find required class' – vinWin Dec 20 '19 at 09:26
  • @vinWin Yes, I realize that. That's the problem of whatever program is trying to run it, NOT the manifest file. Go download pretty much any Apache commons jar and look at the manifest. You'll see things are formatted in the same way, with line breaks right in the middle of file names. – CAustin Dec 20 '19 at 22:40
  • So ideally it is expected to not cause problem with missing class I believe?, but it is resulting in issue. Will double check on that, else I may need to relay on `zip` ant task and explicitly maintaining & packing META-INF/** files.. – vinWin Dec 21 '19 at 22:33

0 Answers0