read build time from META-INF/MANIFEST.MF

Post here questions and problems related to oXygen frameworks/document types.
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

read build time from META-INF/MANIFEST.MF

Post by vishwavaranasi »

hello team , the below method code to read build time from META-INF/MANIFEST.MF works fine in eclipse

where as the same jar deployed to oxygen/plugins folder and then when i try this to from a oxygen plugin its not returning any value?

Code: Select all

public static String getMyOxyegnPluginBuidTime() {

		String buidTime = null;
		try(InputStream manifestStream = MyPluginDetails.class.getClassLoader().getResourceAsStream("META-INF/MANIFEST.MF"))
		{
			Properties prop = new Properties();
			try {
				prop.load(manifestStream);

				buidTime=(prop.getProperty("Build-Time"));
			   
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		} catch (IOException e) {			
			e.printStackTrace();
		}

		
		return buidTime;

	}
Thanks,
vishwa
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: read build time from META-INF/MANIFEST.MF

Post by Radu »

Hi,

I assume you have a plugin which contains a "custom.jar" with a custom "META-INF/MANIFEST.MF" file inside
When the plugin is loaded in Oxygen there are lots of other JAR libraries loaded in the same class loader, some of them with "META-INF/MANIFEST.MF" files, and the MANIFEST.MF will be returned from the first JAR library in the class loader.
So maybe you need to make the code more flexible, get a list of all "MANIFEST.MF" resources from the class loader, iterate it, find the proper URL and read from it:

Code: Select all

      Enumeration<URL> resources = this.getClass().getClassLoader().getResources("/META-INF/MANIFEST.MF");
      while(resources.hasMoreElements()) {
        URL url = resources.nextElement();
        if(url.toString().contains("yourlibrary.jar")) {
          url.openConnection().getInputStream();
        }
      }
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
vishwavaranasi
Posts: 144
Joined: Fri Feb 28, 2020 4:02 pm

Re: read build time from META-INF/MANIFEST.MF

Post by vishwavaranasi »

Thanks Radu,

the MANIFEST file is inside my custom plugin jar ,
Thanks,
vishwa
Post Reply