private String getValueFor(String property) {
   if (property == null) return null;
   String result = TestActivator.getContext().getProperty(property);
   if (result == null && archiveAndRepositoryProperties == null) return null;
   if (result == null) archiveAndRepositoryProperties.getProperty(property);
   if (result == null)
     result = archiveAndRepositoryProperties.getProperty(property + '.' + Platform.getOS());
   return result;
 }
 /**
  * Returns the list of bundles in the osgi.bundles property of the platform config ini, or a set
  * of default bundles if the property could not be found.
  *
  * @return string list of bundles
  */
 public static String getBundleList() {
   Properties properties = getConfigIniProperties();
   String osgiBundles =
       properties == null ? null : properties.getProperty("osgi.bundles"); // $NON-NLS-1$
   if (osgiBundles == null) {
     osgiBundles = getDefaultBundleList();
   } else {
     osgiBundles = stripPathInformation(osgiBundles);
   }
   return osgiBundles;
 }
 private static void loadPlatformZipPropertiesFromFile() {
   File installLocation = getInstallLocation();
   if (installLocation != null) {
     // parent will be "eclipse" and the parent's parent will be "eclipse-testing"
     File parent = installLocation.getParentFile();
     if (parent != null) {
       parent = parent.getParentFile();
       if (parent != null) {
         File propertiesFile = new File(parent, "equinoxp2tests.properties");
         if (!propertiesFile.exists()) return;
         archiveAndRepositoryProperties = new Properties();
         try {
           InputStream is = null;
           try {
             is = new BufferedInputStream(new FileInputStream(propertiesFile));
             archiveAndRepositoryProperties.load(is);
           } finally {
             is.close();
           }
         } catch (IOException e) {
           return;
         }
       }
     }
   }
 }
Esempio n. 4
0
 /** Load any progress information for the import so far. */
 void restore() throws IOException {
   try {
     File dir = getStorageDirectory();
     File index = new File(dir, FILE_INDEX);
     props.load(new FileInputStream(index));
   } catch (FileNotFoundException e) {
     // ok if file doesn't exist yet
   }
 }
Esempio n. 5
0
 private URL getSourceURL() {
   String urlString = props.getProperty(KEY_SOURCE_URL, null);
   try {
     return urlString == null ? null : new URL(urlString);
   } catch (MalformedURLException e) {
     // impossible because we validated URL in the setter method
     throw new RuntimeException(e);
   }
 }
 /*
  * Create a link file in the links folder. Point it to the given extension location.
  */
 public void createLinkFile(String message, String filename, String extensionLocation) {
   File file = new File(output, getRootFolder() + "links/" + filename + ".link");
   file.getParentFile().mkdirs();
   Properties properties = new Properties();
   properties.put("path", extensionLocation);
   OutputStream stream = null;
   try {
     stream = new BufferedOutputStream(new FileOutputStream(file));
     properties.store(stream, null);
   } catch (IOException e) {
     fail(message, e);
   } finally {
     try {
       if (stream != null) stream.close();
     } catch (IOException e) {
       // ignore
     }
   }
 }
 public static Properties getConfigIniProperties() {
   File iniFile =
       new File(TargetPlatform.getLocation(), "configuration/config.ini"); // $NON-NLS-1$
   if (!iniFile.exists()) return null;
   Properties pini = new Properties();
   FileInputStream fis = null;
   try {
     fis = new FileInputStream(iniFile);
     pini.load(fis);
     fis.close();
     return pini;
   } catch (IOException e) {
     MDECore.logException(e);
   } finally {
     try {
       if (fis != null) fis.close();
     } catch (IOException e) {
       MDECore.logException(e);
     }
   }
   return null;
 }
Esempio n. 8
0
  /**
   * Generate an ant script that can be run to generate final p2 metadata for a product. Returns
   * null if p2 bundles aren't available.
   *
   * <p>If no product file is given, the generated p2 call generates final metadata for a
   * ${p2.root.name}_${p2.root.version} IU.
   *
   * <p>versionAdvice is a properties file with bsn=3.2.1.xyz entries
   *
   * @param workingDir - the directory in which to generate the script
   * @param productFileLocation - the location of a .product file (can be null)
   * @param versionAdvice - version advice (can be null)
   * @return The location of the generated script, or null
   * @throws CoreException
   */
  public static String generateP2ProductScript(
      String workingDir, String productFileLocation, Properties versionAdvice)
      throws CoreException {
    if (!loadP2Class()) return null;

    File working = new File(workingDir);
    working.mkdirs();

    File adviceFile = null;
    if (versionAdvice != null) {
      adviceFile = new File(working, "versionAdvice.properties"); // $NON-NLS-1$
      try {
        OutputStream os = new BufferedOutputStream(new FileOutputStream(adviceFile));
        try {
          versionAdvice.store(os, null);
        } finally {
          os.close();
        }
      } catch (IOException e) {
        String message = NLS.bind(Messages.exception_writingFile, adviceFile.toString());
        throw new CoreException(
            new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, e));
      }
    }

    AntScript p2Script = null;
    try {
      p2Script = newAntScript(workingDir, "p2product.xml"); // $NON-NLS-1$
      p2Script.printProjectDeclaration(
          "P2 Product IU Generation", "main", "."); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      p2Script.println();
      p2Script.printProperty(PROPERTY_P2_APPEND, "true"); // $NON-NLS-1$
      p2Script.printProperty(PROPERTY_P2_COMPRESS, "false"); // $NON-NLS-1$
      p2Script.printProperty(PROPERTY_P2_METADATA_REPO_NAME, ""); // $NON-NLS-1$
      p2Script.printProperty(PROPERTY_P2_ARTIFACT_REPO_NAME, ""); // $NON-NLS-1$
      p2Script.printTargetDeclaration(
          "main",
          null,
          TARGET_P2_METADATA,
          null,
          "Generate the final Product IU"); //$NON-NLS-1$//$NON-NLS-2$
      generateP2FinalCall(
          p2Script, productFileLocation, adviceFile != null ? adviceFile.getAbsolutePath() : null);
      p2Script.printTargetEnd();
      p2Script.printProjectEnd();
    } finally {
      if (p2Script != null) p2Script.close();
    }
    return workingDir + "/p2product.xml"; // $NON-NLS-1$
  }
  public static Dictionary[] getPlatformProperties(String[] profiles, MinimalState state) {
    if (profiles == null || profiles.length == 0)
      return new Dictionary[] {getTargetEnvironment(state)};

    // add java profiles for those EE's that have a .profile file in the current system bundle
    ArrayList result = new ArrayList(profiles.length);
    for (int i = 0; i < profiles.length; i++) {
      IExecutionEnvironment environment =
          JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(profiles[i]);
      if (environment != null) {
        Properties profileProps = environment.getProfileProperties();
        if (profileProps != null) {
          Dictionary props = TargetPlatformHelper.getTargetEnvironment(state);
          String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
          if (systemPackages != null) props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages);
          String ee = profileProps.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
          if (ee != null) props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
          result.add(props);
        }
      }
    }
    if (result.size() > 0) return (Dictionary[]) result.toArray(new Dictionary[result.size()]);
    return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment(state)};
  }
Esempio n. 10
0
 void save() throws IOException {
   File dir = getStorageDirectory();
   dir.mkdirs();
   File index = new File(dir, FILE_INDEX);
   props.store(new FileOutputStream(index), null);
 }
Esempio n. 11
0
 /** Returns the number of bytes transferred so far. */
 private Integer getTransferred() {
   return Integer.valueOf(props.getProperty(KEY_TRANSFERRED, "0")); // $NON-NLS-1$
 }
Esempio n. 12
0
 private void setTransferred(int transferred) {
   props.put(KEY_TRANSFERRED, Integer.toString(transferred));
 }
Esempio n. 13
0
 public void setOptions(String options) {
   props.put(KEY_OPTIONS, options == null ? "" : options); // $NON-NLS-1$
 }
Esempio n. 14
0
 private String getFileName() {
   return props.getProperty(KEY_FILE_NAME, ""); // $NON-NLS-1$
 }
Esempio n. 15
0
 public void setFileName(String name) {
   props.put(KEY_FILE_NAME, name == null ? "" : name); // $NON-NLS-1$
 }
Esempio n. 16
0
 private int getLength() {
   return Integer.valueOf(props.getProperty(KEY_LENGTH, "0")); // $NON-NLS-1$
 }
Esempio n. 17
0
 /** Sets the total length of the file being imported. */
 public void setLength(long length) {
   props.put(KEY_LENGTH, Long.toString(length));
 }
Esempio n. 18
0
 private List<String> getOptions() {
   return TransferServlet.getOptions(props.getProperty(KEY_OPTIONS, "")); // $NON-NLS-1$
 }
Esempio n. 19
0
 /** Sets the path of the file in the workspace once the import completes. */
 public void setPath(IPath path) {
   props.put(KEY_PATH, path.toString());
 }
Esempio n. 20
0
 private String getPath() {
   return props.getProperty(KEY_PATH, ""); // $NON-NLS-1$
 }
Esempio n. 21
0
 /** Sets the URL of the file to be imported (optional). */
 public void setSourceURL(String urlString) throws MalformedURLException {
   // ensure it is a valid absolute URL
   if (new URL(urlString).getProtocol() == null)
     throw new MalformedURLException(NLS.bind("Expected an absolute URI: {0}", urlString));
   props.put(KEY_SOURCE_URL, urlString);
 }
  private void saveConfigurationFile(ILaunchConfiguration configuration) throws CoreException {
    Properties properties = new Properties();
    properties.setProperty(
        "osgi.install.area", "file:" + TargetPlatform.getLocation()); // $NON-NLS-1$ //$NON-NLS-2$
    properties.setProperty("osgi.configuration.cascaded", "false"); // $NON-NLS-1$ //$NON-NLS-2$
    properties.put(
        "osgi.framework",
        LaunchConfigurationHelper.getBundleURL(
            IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); // $NON-NLS-1$
    int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
    properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); // $NON-NLS-1$
    boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true);

    String bundles = null;
    if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {

      // If update configurator is set to its default start level, override it as simple/update
      // configurators should not be autostarted together
      Object updateConfiguratorBundle =
          fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR);
      if (updateConfiguratorBundle != null) {
        String startLevel = (String) fModels.get(updateConfiguratorBundle);
        if (startLevel != null
            && startLevel.equals(BundleLauncherHelper.DEFAULT_UPDATE_CONFIGURATOR_START_LEVEL)) {
          fModels.put(updateConfiguratorBundle, "4:false"); // $NON-NLS-1$
        }
      }

      // If simple configurator is being used, we need to write out the bundles.txt instead of
      // writing out the list in the config.ini
      URL bundlesTxt =
          P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null);
      if (bundlesTxt != null) {
        properties.setProperty(
            "org.eclipse.equinox.simpleconfigurator.configUrl",
            bundlesTxt.toString()); // $NON-NLS-1$
        if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
          properties.setProperty(
              "org.eclipse.update.reconcile", "false"); // $NON-NLS-1$ //$NON-NLS-2$
        }
      }
      StringBuffer buffer = new StringBuffer();
      IMonitorModelBase model =
          (IMonitorModelBase) fAllBundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR);
      buffer.append(LaunchConfigurationHelper.getBundleURL(model, true));
      appendStartData(buffer, (String) fModels.get(model), autostart);
      bundles = buffer.toString();
    } else {
      bundles = getBundles(autostart);
    }
    if (bundles.length() > 0) properties.put("osgi.bundles", bundles); // $NON-NLS-1$

    if (!"3.3"
        .equals(
            configuration.getAttribute(
                IPDEConstants.LAUNCHER_PDE_VERSION, ""))) { // $NON-NLS-1$ //$NON-NLS-2$
      properties.put("eclipse.ignoreApp", "true"); // $NON-NLS-1$ //$NON-NLS-2$
      properties.put("osgi.noShutdown", "true"); // $NON-NLS-1$ //$NON-NLS-2$
    }

    LaunchConfigurationHelper.save(
        new File(getConfigDir(configuration), "config.ini"), properties); // $NON-NLS-1$
  }