/** * Creates an artifact descriptor for the given key and path. * @param info the publisher info * @param key the key of the artifact to publish * @param pathOnDisk the path of the artifact on disk * @return a new artifact descriptor */ public static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactKey key, File pathOnDisk) { return createArtifactDescriptor(info, info.getArtifactRepository(), key, pathOnDisk); }
/** * Loop over the known metadata repositories looking for the given IU within a particular range * @param publisherResult * @param iuId the id of the IU to look for * @param versionRange the version range to consider * @return The the IUs with the matching ids in the given range */ protected IQueryResult<IInstallableUnit> queryForIUs(IPublisherResult publisherResult, String iuId, VersionRange versionRange) { IQuery<IInstallableUnit> query = null; IQueryResult<IInstallableUnit> queryResult = Collector.emptyCollector(); query = QueryUtil.createIUQuery(iuId, versionRange); NullProgressMonitor progress = new NullProgressMonitor(); if (publisherResult != null) queryResult = publisherResult.query(query, progress); if (queryResult.isEmpty() && info.getMetadataRepository() != null) queryResult = info.getMetadataRepository().query(query, progress); if (queryResult.isEmpty() && info.getContextMetadataRepository() != null) queryResult = info.getContextMetadataRepository().query(query, progress); return queryResult; }
private IBrandingAdvice getBrandingAdvice() { // there is expected to only be one branding advice for a given configspec so // just return the first one we find. Collection<IBrandingAdvice> advice = info.getAdvice(configSpec, true, null, null, IBrandingAdvice.class); for (Iterator<IBrandingAdvice> i = advice.iterator(); i.hasNext();) return i.next(); return null; }
protected void createRootFilesAdvice() { File[] baseExclusions = computeRootFileExclusions(); if (baseExclusions != null) info.addAdvice(new RootFilesAdvice(null, null, baseExclusions, null)); String[] configs = info.getConfigurations(); for (int i = 0; i < configs.length; i++) info.addAdvice(computeRootFileAdvice(configs[i])); }
protected Transport getTransport(IPublisherInfo info) { @SuppressWarnings("rawtypes") IRepository repo = info.getMetadataRepository(); if (repo == null) repo = info.getArtifactRepository(); if (repo == null) throw new IllegalStateException("The transport service can not be found."); //$NON-NLS-1$ return (Transport) repo.getProvisioningAgent().getService(Transport.SERVICE_NAME); } }
@Override protected void publishArtifact(IArtifactDescriptor descriptor, File jarFile, IPublisherInfo publisherInfo) { // no files to publish so this is done. if (jarFile == null || publisherInfo == null) return; // if the destination already contains the descriptor, there is nothing to do. IArtifactRepository destination = publisherInfo.getArtifactRepository(); if (destination == null || destination.contains(descriptor)) return; super.publishArtifact(descriptor, jarFile, publisherInfo); // if we are assimilating pack200 files then add the packed descriptor // into the repo assuming it does not already exist. boolean reuse = "true".equals(destination.getProperties().get(AbstractPublisherApplication.PUBLISH_PACK_FILES_AS_SIBLINGS)); //$NON-NLS-1$ if (reuse && (publisherInfo.getArtifactOptions() & IPublisherInfo.A_PUBLISH) > 0) { File packFile = new Path(jarFile.getAbsolutePath()).addFileExtension("pack.gz").toFile(); //$NON-NLS-1$ if (packFile.exists()) { IArtifactDescriptor ad200 = createPack200ArtifactDescriptor(descriptor.getArtifactKey(), packFile, descriptor.getProperty(IArtifactDescriptor.ARTIFACT_SIZE)); publishArtifact(ad200, packFile, publisherInfo); } } }
protected void savePublishedIUs() { IMetadataRepository metadataRepository = info.getMetadataRepository(); if (metadataRepository != null) { Collection<IInstallableUnit> ius = results.getIUs(null, null); metadataRepository.addInstallableUnits(ius); } } }
protected IPublisherAction[] createActions() { createAdvice(); ArrayList<IPublisherAction> actions = new ArrayList<>(); // create an action that just publishes the raw bundles and features IPublisherAction action = new MergeResultsAction(new IPublisherAction[] {createFeaturesAction(), createBundlesAction()}, IPublisherResult.MERGE_ALL_ROOT); actions.add(action); actions.add(createApplicationExecutableAction(info.getConfigurations())); actions.add(createRootFilesAction()); actions.addAll(createAccumulateConfigDataActions(info.getConfigurations())); actions.add(createJREAction()); actions.add(createConfigCUsAction()); actions.add(createDefaultCUsAction()); actions.add(createRootIUAction()); return actions.toArray(new IPublisherAction[actions.size()]); }
@Override public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) { IPublisherResult innerResult = new PublisherResult(); this.outerResults = results; this.info = publisherInfo; // we have N platforms, generate a CU for each // TODO try and find common properties across platforms String[] configSpecs = publisherInfo.getConfigurations(); for (int i = 0; i < configSpecs.length; i++) { if (monitor.isCanceled()) return Status.CANCEL_STATUS; String configSpec = configSpecs[i]; Collection<IConfigAdvice> configAdvice = publisherInfo.getAdvice(configSpec, false, id, version, IConfigAdvice.class); BundleInfo[] bundles = fillInBundles(configAdvice, results); publishBundleCUs(publisherInfo, bundles, configSpec, innerResult); publishConfigIUs(configAdvice, innerResult, configSpec); Collection<IExecutableAdvice> launchingAdvice = publisherInfo.getAdvice(configSpec, false, id, version, IExecutableAdvice.class); publishIniIUs(launchingAdvice, innerResult, configSpec); } // merge the IUs into the final result as non-roots and create a parent IU that captures them all results.merge(innerResult, IPublisherResult.MERGE_ALL_NON_ROOT); publishTopLevelConfigurationIU(innerResult.getIUs(null, IPublisherResult.ROOT), results); return Status.OK_STATUS; }
private static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactRepository artifactRepo, IArtifactKey key, File pathOnDisk) { IArtifactDescriptor result = artifactRepo != null ? artifactRepo.createArtifactDescriptor(key) : new ArtifactDescriptor(key); if (result instanceof ArtifactDescriptor) { if (pathOnDisk != null && pathOnDisk.isFile()) { ArtifactDescriptor descriptor = (ArtifactDescriptor) result; descriptor.setProperty(IArtifactDescriptor.ARTIFACT_SIZE, Long.toString(pathOnDisk.length())); descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(pathOnDisk.length())); boolean generateChecksums = info == null || (info.getArtifactOptions() & IPublisherInfo.A_NO_MD5) == 0; if (generateChecksums) { calculateChecksums(pathOnDisk, descriptor); } } } return result; }
/** * Create and register advice that will tell people what versions of the launcher bundle and * fragments are in use in this particular result. */ private void createLauncherAdvice(IPublisherInfo publisherInfo, IPublisherResult results) { Collection<IInstallableUnit> ius = getIUs(results.getIUs(null, null), EquinoxLauncherCUAction.ORG_ECLIPSE_EQUINOX_LAUNCHER); if (publisherInfo.getContextMetadataRepository() != null) ius.addAll(getIUs(publisherInfo.getContextMetadataRepository().query(QueryUtil.ALL_UNITS, null).toUnmodifiableSet(), EquinoxLauncherCUAction.ORG_ECLIPSE_EQUINOX_LAUNCHER)); VersionAdvice advice = new VersionAdvice(); boolean found = false; for (IInstallableUnit iu : ius) { // skip over source bundles and fragments // TODO should we use the source property here rather than magic name matching? if (iu.getId().endsWith(".source") || QueryUtil.isFragment(iu)) //$NON-NLS-1$ continue; advice.setVersion(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), iu.getVersion()); found = true; } if (found) publisherInfo.addAdvice(advice); }
@Override protected void publishArtifact(IArtifactDescriptor descriptor, File jarFile, IPublisherInfo publisherInfo) { // no files to publish so this is done. if (jarFile == null || publisherInfo == null) return; // if the destination already contains the descriptor, there is nothing to do. IArtifactRepository destination = publisherInfo.getArtifactRepository(); if (destination == null || destination.contains(descriptor)) return; super.publishArtifact(descriptor, jarFile, publisherInfo); // if we are assimilating pack200 files then add the packed descriptor // into the repo assuming it does not already exist. boolean reuse = "true".equals(destination.getProperties().get(AbstractPublisherApplication.PUBLISH_PACK_FILES_AS_SIBLINGS)); //$NON-NLS-1$ if (reuse && (publisherInfo.getArtifactOptions() & IPublisherInfo.A_PUBLISH) > 0) { File packFile = new Path(jarFile.getAbsolutePath()).addFileExtension("pack.gz").toFile(); //$NON-NLS-1$ if (packFile.exists()) { IArtifactDescriptor ad200 = createPack200ArtifactDescriptor(descriptor.getArtifactKey(), packFile, descriptor.getProperty(IArtifactDescriptor.ARTIFACT_SIZE)); publishArtifact(ad200, packFile, publisherInfo); } } }
protected void createRootFilesAdvice() { File[] baseExclusions = computeRootFileExclusions(); if (baseExclusions != null) info.addAdvice(new RootFilesAdvice(null, null, baseExclusions, null)); String[] configs = info.getConfigurations(); for (int i = 0; i < configs.length; i++) info.addAdvice(computeRootFileAdvice(configs[i])); }
protected void savePublishedIUs() { IMetadataRepository metadataRepository = info.getMetadataRepository(); if (metadataRepository != null) { Collection<IInstallableUnit> ius = results.getIUs(null, null); metadataRepository.addInstallableUnits(ius); } } }
protected IPublisherAction[] createActions() { createAdvice(); ArrayList<IPublisherAction> actions = new ArrayList<IPublisherAction>(); // create an action that just publishes the raw bundles and features IPublisherAction action = new MergeResultsAction(new IPublisherAction[] {createFeaturesAction(), createBundlesAction()}, IPublisherResult.MERGE_ALL_ROOT); actions.add(action); actions.add(createApplicationExecutableAction(info.getConfigurations())); actions.add(createRootFilesAction()); actions.addAll(createAccumulateConfigDataActions(info.getConfigurations())); actions.add(createJREAction()); actions.add(createConfigCUsAction()); actions.add(createDefaultCUsAction()); actions.add(createRootIUAction()); return actions.toArray(new IPublisherAction[actions.size()]); }
public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) { IPublisherResult innerResult = new PublisherResult(); this.outerResults = results; this.info = publisherInfo; // we have N platforms, generate a CU for each // TODO try and find common properties across platforms String[] configSpecs = publisherInfo.getConfigurations(); for (int i = 0; i < configSpecs.length; i++) { if (monitor.isCanceled()) return Status.CANCEL_STATUS; String configSpec = configSpecs[i]; Collection<IConfigAdvice> configAdvice = publisherInfo.getAdvice(configSpec, false, id, version, IConfigAdvice.class); BundleInfo[] bundles = fillInBundles(configAdvice, results); publishBundleCUs(publisherInfo, bundles, configSpec, innerResult); publishConfigIUs(configAdvice, innerResult, configSpec); Collection<IExecutableAdvice> launchingAdvice = publisherInfo.getAdvice(configSpec, false, id, version, IExecutableAdvice.class); publishIniIUs(launchingAdvice, innerResult, configSpec); } // merge the IUs into the final result as non-roots and create a parent IU that captures them all results.merge(innerResult, IPublisherResult.MERGE_ALL_NON_ROOT); publishTopLevelConfigurationIU(innerResult.getIUs(null, IPublisherResult.ROOT), results); return Status.OK_STATUS; }
private static IArtifactDescriptor createArtifactDescriptor(IPublisherInfo info, IArtifactRepository artifactRepo, IArtifactKey key, File pathOnDisk) { IArtifactDescriptor result = artifactRepo != null ? artifactRepo.createArtifactDescriptor(key) : new ArtifactDescriptor(key); if (result instanceof ArtifactDescriptor) { ArtifactDescriptor descriptor = (ArtifactDescriptor) result; if (pathOnDisk != null) { descriptor.setProperty(IArtifactDescriptor.ARTIFACT_SIZE, Long.toString(pathOnDisk.length())); descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_SIZE, Long.toString(pathOnDisk.length())); } if (info == null || (info.getArtifactOptions() & IPublisherInfo.A_NO_MD5) == 0) { String md5 = computeMD5(pathOnDisk); if (md5 != null) descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, md5); } } return result; }
/** * Create and register advice that will tell people what versions of the launcher bundle and * fragments are in use in this particular result. */ private void createLauncherAdvice(IPublisherInfo publisherInfo, IPublisherResult results) { Collection<IInstallableUnit> ius = getIUs(results.getIUs(null, null), EquinoxLauncherCUAction.ORG_ECLIPSE_EQUINOX_LAUNCHER); if (publisherInfo.getContextMetadataRepository() != null) ius.addAll(getIUs(publisherInfo.getContextMetadataRepository().query(QueryUtil.ALL_UNITS, null).toUnmodifiableSet(), EquinoxLauncherCUAction.ORG_ECLIPSE_EQUINOX_LAUNCHER)); VersionAdvice advice = new VersionAdvice(); boolean found = false; for (IInstallableUnit iu : ius) { // skip over source bundles and fragments // TODO should we use the source property here rather than magic name matching? if (iu.getId().endsWith(".source") || QueryUtil.isFragment(iu)) //$NON-NLS-1$ continue; advice.setVersion(IInstallableUnit.NAMESPACE_IU_ID, iu.getId(), iu.getVersion()); found = true; } if (found) publisherInfo.addAdvice(advice); }
protected void storeConfigData(IPublisherInfo publisherInfo, String config, IPublisherResult result) { ConfigData data = loader.getConfigData(); if (data == null) return; publisherInfo.addAdvice(new ConfigAdvice(data, config)); LauncherData launcherData = loader.getLauncherData(); if (launcherData == null) return; publisherInfo.addAdvice(new LaunchingAdvice(launcherData, config)); } }