org.eclipse.equinox.p2.metadata.IInstallableUnit Java Examples
The following examples show how to use
org.eclipse.equinox.p2.metadata.IInstallableUnit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstallWizardOpener.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public void open(Map<String, Set<String>> features, IProgressMonitor monitor) { try { IProvisioningAgent agent = agentProvider.get(); IMetadataRepositoryManager manager = (IMetadataRepositoryManager) agent .getService(IMetadataRepositoryManager.SERVICE_NAME); Set<IInstallableUnit> units = collectIUs(features, manager, monitor); if (monitor.isCanceled()) return; List<URI> knownRepos = Arrays.asList(manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)); InstallOperation op = new OperationFactory().createInstallOperation(units, knownRepos, monitor); agent.stop(); open(units, op); } catch (ProvisionException e) { e.printStackTrace(); } }
Example #2
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private String prefixGroupId ( final IInstallableUnit iu, String groupId ) { final String replacementGroupId = this.properties.getProperty ( String.format ( "map.group.id.by.iu.%s", iu.getId () ) ); if ( replacementGroupId != null ) { // we still need to apply the global mapping groupId = replacementGroupId; } if ( groupId == null || REPLACE_GROUP_ID_PREFIX == null ) { return groupId; } if ( groupId.startsWith ( REPLACE_GROUP_ID_PREFIX ) ) { return REPLACE_GROUP_ID_VALUE + groupId.substring ( REPLACE_GROUP_ID_PREFIX.length () ); } return groupId; }
Example #3
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private List<MavenReference> fromValue ( final IInstallableUnit iu, final String value ) throws Exception { final String[] segs = value.split ( "," ); final List<MavenReference> result = new ArrayList<> ( segs.length ); for ( final String seg : segs ) { final String[] toks = seg.split ( "\\:" ); if ( toks.length == 3 ) { final String version = MessageFormat.format ( toks[2], getSegments ( iu.getVersion () ) ); result.add ( new MavenReference ( toks[0], toks[1], version ) ); } else if ( toks.length == 2 ) { // automatic version result.add ( new MavenReference ( toks[0], toks[1], makeVersion ( iu, false ) ) ); } else { throw new IllegalArgumentException ( String.format ( "Maven reference has invalid syntax: %s", value ) ); } } return result; }
Example #4
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private String makeGroupIdFromIU ( final IInstallableUnit iu ) { final String name = getName ( iu ); final String toks[] = name.split ( "\\.", 3 ); final StringBuilder sb = new StringBuilder (); for ( int i = 0; i < toks.length; i++ ) { if ( i > 0 ) { sb.append ( '.' ); } sb.append ( toks[i] ); } return sb.toString (); }
Example #5
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private boolean ignoreMirror ( final IInstallableUnit iu ) { String value = this.properties.getProperty ( "mirror." + iu.getId (), null ); if ( value != null ) { return !Boolean.parseBoolean ( value ); } value = this.properties.getProperty ( "external." + iu.getId () ); if ( value != null ) { return true; } // default return false; }
Example #6
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public String makeVersion ( final IInstallableUnit iu, final boolean withQualifier ) throws Exception { Version version; final String tychoVersion = iu.getProperty ( "maven-version" ); if ( !IGNORE_TYCHO && tychoVersion != null ) { final IVersionFormat format = Version.compile ( "n[.n=0;[.n=0;[.n=0;]]][[-.]S='';]" ); version = format.parse ( tychoVersion ); } else { version = iu.getVersion (); } if ( withQualifier ) { return toString ( version ); } else { return withoutQualifier ( version ); } }
Example #7
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private Set<MavenDependency> makeDependencies ( final IInstallableUnit iu, final IProgressMonitor pm ) throws Exception { final Set<MavenDependency> result = new HashSet<> (); for ( final IRequirement req : iu.getRequirements () ) { if ( ! ( req instanceof IRequiredCapability ) ) { continue; } final List<MavenDependency> deps = makeDependency ( iu, (IRequiredCapability)req, pm ); if ( deps != null ) { result.addAll ( deps ); } } return result; }
Example #8
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private Set<MavenDependency> makeDependencies ( final IInstallableUnit iu, final IProgressMonitor pm ) throws Exception { final Set<MavenDependency> result = new HashSet<> (); for ( final IRequirement req : iu.getRequirements () ) { if ( ! ( req instanceof IRequiredCapability ) ) { continue; } final List<MavenDependency> deps = makeDependency ( iu, (IRequiredCapability)req, pm ); if ( deps != null ) { result.addAll ( deps ); } } return result; }
Example #9
Source File: InstallationChecker.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public boolean isFeatureInstalled(String featureId) { try { IProvisioningAgent agent = agentProvider.get(); IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); IProfile selfProfile = profileRegistry.getProfile(IProfileRegistry.SELF); if(selfProfile == null) return true; Set<IInstallableUnit> installed = selfProfile .available(QueryUtil.createIUQuery(featureId), new NullProgressMonitor()).toUnmodifiableSet(); agent.stop(); return !installed.isEmpty(); } catch (ProvisionException e) { e.printStackTrace(); } return false; }
Example #10
Source File: UpdateManager.java From developer-studio with Apache License 2.0 | 6 votes |
/** * Set the selected new features to install. * * @param selectedDevSFeatures * Features to install. */ public void setSelectedFeaturesToInstall(List<EnhancedFeature> selectedDevSFeatures) { this.selectedFeatures = new ArrayList<IInstallableUnit>(); for (EnhancedFeature devStudioFeature : selectedDevSFeatures) { selectedFeatures.add(allAvailableFeatures.get(devStudioFeature.getId())); if (devStudioFeature.getChildFeatures() != null && devStudioFeature.getChildFeatures().length != 0) { String[] childFeaturesToInstall = devStudioFeature.getChildFeatures(); for (String childFeature : childFeaturesToInstall) {// set all // children // of // selected // features String featureID = childFeature + ".feature.group"; selectedFeatures.add(allAvailableFeatures.get(featureID)); } } } }
Example #11
Source File: UpdateManager.java From developer-studio with Apache License 2.0 | 6 votes |
private EnhancedFeature readEnhancedMetadata(IInstallableUnit iu, File cachedFeatureDir) { EnhancedFeature feature = new EnhancedFeature(iu); feature.setIconURL(FILE_PROTOCOL + cachedFeatureDir + File.separator + ICON_FILE); try { File updateProperties = new File(cachedFeatureDir, UPDATE_PROPERTIES_FILE); Properties prop = new Properties(); InputStream input = new FileInputStream(updateProperties); prop.load(input); feature.setWhatIsNew(prop.getProperty(PROP_WHAT_IS_NEW)); feature.setBugFixes(prop.getProperty(PROP_BUG_FIXES)); feature.setKernelFeature(Boolean.parseBoolean(prop.getProperty(PROP_IS_KERNEL_FEATURE))); feature.setHidden(Boolean.parseBoolean(prop.getProperty(PROP_IS_HIDDEN))); String childrenStr = prop.getProperty(CHILD_FEATURES); feature.setChildFeatures(childrenStr.split(",")); } catch (Exception e) { // ignore - Additional meta-data was not provided in feature.jar // log.error(e); } return feature; }
Example #12
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public String makeVersion ( final IInstallableUnit iu, final boolean withQualifier ) throws Exception { Version version; final String tychoVersion = iu.getProperty ( "maven-version" ); if ( !IGNORE_TYCHO && tychoVersion != null ) { final IVersionFormat format = Version.compile ( "n[.n=0;[.n=0;[.n=0;]]][[-.]S='';]" ); version = format.parse ( tychoVersion ); } else { version = iu.getVersion (); } if ( withQualifier ) { return toString ( version ); } else { return withoutQualifier ( version ); } }
Example #13
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private String makeGroupIdFromIU ( final IInstallableUnit iu ) { final String name = getName ( iu ); final String toks[] = name.split ( "\\.", 3 ); final StringBuilder sb = new StringBuilder (); for ( int i = 0; i < toks.length; i++ ) { if ( i > 0 ) { sb.append ( '.' ); } sb.append ( toks[i] ); } return sb.toString (); }
Example #14
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private List<MavenReference> fromValue ( final IInstallableUnit iu, final String value ) throws Exception { final String[] segs = value.split ( "," ); final List<MavenReference> result = new ArrayList<> ( segs.length ); for ( final String seg : segs ) { final String[] toks = seg.split ( "\\:" ); if ( toks.length == 3 ) { final String version = MessageFormat.format ( toks[2], getSegments ( iu.getVersion () ) ); result.add ( new MavenReference ( toks[0], toks[1], version ) ); } else if ( toks.length == 2 ) { // automatic version result.add ( new MavenReference ( toks[0], toks[1], makeVersion ( iu, false ) ) ); } else { throw new IllegalArgumentException ( String.format ( "Maven reference has invalid syntax: %s", value ) ); } } return result; }
Example #15
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private String prefixGroupId ( final IInstallableUnit iu, String groupId ) { final String replacementGroupId = this.properties.getProperty ( String.format ( "map.group.id.by.iu.%s", iu.getId () ) ); if ( replacementGroupId != null ) { // we still need to apply the global mapping groupId = replacementGroupId; } if ( groupId == null || REPLACE_GROUP_ID_PREFIX == null ) { return groupId; } if ( groupId.startsWith ( REPLACE_GROUP_ID_PREFIX ) ) { return REPLACE_GROUP_ID_VALUE + groupId.substring ( REPLACE_GROUP_ID_PREFIX.length () ); } return groupId; }
Example #16
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private boolean ignoreMirror ( final IInstallableUnit iu ) { String value = this.properties.getProperty ( "mirror." + iu.getId (), null ); if ( value != null ) { return !Boolean.parseBoolean ( value ); } value = this.properties.getProperty ( "external." + iu.getId () ); if ( value != null ) { return true; } // default return false; }
Example #17
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void processInternal ( final IProgressMonitor pm ) throws ProvisionException, Exception { this.output.mkdirs (); System.out.println ( "Loading metadata..." ); this.metaRepo = this.metaManager.loadRepository ( this.repositoryLocation, pm ); System.out.println ( "Loading artifacts..." ); this.artRepo = this.artManager.loadRepository ( this.repositoryLocation, pm ); System.out.println ( "done!" ); for ( final URI uri : this.validationRepositoryUris ) { System.out.format ( "Loading validation repository: %s%n", uri ); final IMetadataRepository repo = this.metaManager.loadRepository ( uri, pm ); this.validationRepositories.put ( uri, repo ); System.out.println ( "Done!" ); } final IQuery<IInstallableUnit> query = QueryUtil.createIUAnyQuery (); final IQueryResult<IInstallableUnit> result = this.metaRepo.query ( query, pm ); for ( final IInstallableUnit iu : result ) { processUnit ( iu, pm ); } writeUploadScript (); for ( final Map.Entry<MavenReference, Set<String>> entry : this.metadata.entrySet () ) { writeMetaData ( entry.getKey (), entry.getValue () ); } }
Example #18
Source File: LicenseProvider.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public List<License> getLicenses ( final IInstallableUnit iu ) { final String id = this.properties.getProperty ( "license.for." + iu.getId () ); if ( id == null || id.isEmpty () ) { return null; } final String[] ids = id.split ( "," ); if ( ids.length == 0 ) { return null; } final List<License> result = new ArrayList<> ( ids.length ); for ( final String lid : ids ) { final License lic = this.licenses.get ( lid ); if ( lic != null ) { result.add ( lic ); } else { result.add ( parseLicense ( lid ) ); } } return result; }
Example #19
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void processMainArtifact ( final IInstallableUnit iu, final IProgressMonitor pm, final MavenReference ref, final Path versionBase ) throws Exception { final Set<MavenDependency> deps = makeDependencies ( iu, pm ); makePom ( ref, versionBase, deps, iu ); makeMetaData ( ref, versionBase ); makeFake ( ref, versionBase, "javadoc" ); makeFake ( ref, versionBase, "sources" ); this.mavenDependencies.addAll ( deps ); }
Example #20
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public List<MavenReference> makeReference ( final IInstallableUnit iu ) throws Exception { if ( this.defaultIgnores.contains ( iu.getId () ) ) { return null; } String value = this.properties.getProperty ( "mapping." + iu.getId () ); if ( value != null ) { if ( value.isEmpty () ) { return null; // ignore } return fromValue ( iu, value ); } value = this.properties.getProperty ( "external." + iu.getId () ); if ( value != null ) { if ( value.isEmpty () ) { return null; // ignore } return fromValue ( iu, value ); } final MavenReference result = new MavenReference (); result.setGroupId ( makeGroupId ( iu ) ); result.setArtifactId ( makeArtifactId ( iu ) ); result.setVersion ( makeVersion ( iu, !STRIP_QUALIFIER ) ); result.setClassifier ( makeClassifier ( iu ) ); return Collections.singletonList ( result ); }
Example #21
Source File: UpdateMetaFileReaderJob.java From developer-studio with Apache License 2.0 | 5 votes |
private IStatus checkIfUpdatesAvailable(IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateCheckerJob_1, SUB_MONITOR_INDEX); Collection<IInstallableUnit> installedWSO2Features = updateManager .getInstalledWSO2Features(progress.newChild(1)); BufferedReader buffReader = downloadMetaFile(); // read the meta file if (buffReader == null) { promptUserError(Messages.UpdateMetaFileReaderJob_3, ERROR_TITLE); return Status.CANCEL_STATUS; } Map<String, String> availaleDevStudioFeatureVerions = new HashMap<String, String>(); availaleDevStudioFeatureVerions = readMetaDataFiletoMap(buffReader); deleteDownloadedTempFile(); if (availaleDevStudioFeatureVerions.isEmpty()) { log.error(Messages.UpdateCheckerJob_4); return Status.CANCEL_STATUS; } for (IInstallableUnit iInstallableUnit : installedWSO2Features) { if (availaleDevStudioFeatureVerions.containsKey(iInstallableUnit.getId())) { Version availableVersion = generateVersionFromString( availaleDevStudioFeatureVerions.get(iInstallableUnit.getId())); Version upperLimit = generateUpperLimitforUpdates(iInstallableUnit.getVersion()); if (availableVersion != null && availableVersion.compareTo(iInstallableUnit.getVersion()) == AVAILABLE_VERSION_GREATER && availableVersion.compareTo(upperLimit) == AVAILABLE_VERSION_LESS) { updateCount = updateCount + 1; } else if (availableVersion == null) { log.error(Messages.UpdateCheckerJob_4); promptUserError(ERROR_MESSAGE, ERROR_TITLE); return Status.CANCEL_STATUS; } } } if (updateCount > 0) { return Status.OK_STATUS; // OK if there are updates } return Status.CANCEL_STATUS; }
Example #22
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private IArtifactKey findArtifact ( final IInstallableUnit iu ) { for ( final IArtifactKey key : iu.getArtifacts () ) { if ( "osgi.bundle".equals ( key.getClassifier () ) ) { return key; } } return null; }
Example #23
Source File: DefaultMavenMapping.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public String makeArtifactId ( final IInstallableUnit iu ) { final String name = iu.getProperty ( "maven-artifactId" ); if ( name != null ) { return name; } return getName ( iu ); }
Example #24
Source File: LicenseProvider.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public List<License> getLicenses ( final IInstallableUnit iu ) { final String id = this.properties.getProperty ( "license.for." + iu.getId () ); if ( id == null || id.isEmpty () ) { return null; } final String[] ids = id.split ( "," ); if ( ids.length == 0 ) { return null; } final List<License> result = new ArrayList<> ( ids.length ); for ( final String lid : ids ) { final License lic = this.licenses.get ( lid ); if ( lic != null ) { result.add ( lic ); } else { result.add ( parseLicense ( lid ) ); } } return result; }
Example #25
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public void process ( final IProgressMonitor pm ) throws Exception { this.output.mkdirs (); System.out.println ( "Loading metadata..." ); this.metaRepo = this.metaManager.loadRepository ( this.repositoryLocation, pm ); System.out.println ( "Loading artifacts..." ); this.artRepo = this.artManager.loadRepository ( this.repositoryLocation, pm ); System.out.println ( "done!" ); for ( final URI uri : this.validationRepositoryUris ) { System.out.format ( "Loading validation repository: %s%n", uri ); final IMetadataRepository repo = this.metaManager.loadRepository ( uri, pm ); this.validationRepositories.put ( uri, repo ); System.out.println ( "Done!" ); } final IQuery<IInstallableUnit> query = QueryUtil.createIUAnyQuery (); final IQueryResult<IInstallableUnit> result = this.metaRepo.query ( query, pm ); for ( final IInstallableUnit iu : result ) { processUnit ( iu, pm ); } writeUploadScript (); for ( final Map.Entry<MavenReference, Set<String>> entry : this.metadata.entrySet () ) { writeMetaData ( entry.getKey (), entry.getValue () ); } }
Example #26
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void processMainArtifact ( final IInstallableUnit iu, final IProgressMonitor pm, final MavenReference ref, final Path versionBase ) throws Exception { final Set<MavenDependency> deps = makeDependencies ( iu, pm ); makePom ( ref, versionBase, deps, iu ); makeMetaData ( ref, versionBase ); makeFake ( ref, versionBase, "javadoc" ); makeFake ( ref, versionBase, "sources" ); this.mavenDependencies.addAll ( deps ); }
Example #27
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private String makeProjectUrl ( final IInstallableUnit iu ) { String url = iu.getProperty ( "org.eclipse.equinox.p2.doc.url", null ); if ( url == null || url.isEmpty () ) { url = this.properties.getProperty ( "default.project.url" ); } return url; }
Example #28
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void makeScm ( final IInstallableUnit iu, final Document doc, final Element project, final Path versionBase, final MavenReference ref ) { String scm = null; String scmUrl = null; // try override scmUrl = this.properties.getProperty ( "scm.url." + iu.getId () ); scm = this.properties.getProperty ( "scm.ref." + iu.getId () ); // try load and map if ( scmUrl == null ) { scm = loadScm ( versionBase, ref ); if ( scm != null ) { final String[] scmToks = scm.split ( ";", 2 ); if ( scmToks.length > 0 ) { final String key = "scm.url." + scmToks[0]; scmUrl = this.properties.getProperty ( key ); } } } if ( scmUrl == null ) { this.errors.add ( String.format ( "%s: no SCM information", iu.getId () ) ); return; } final Element scmEle = doc.createElement ( "scm" ); project.appendChild ( scmEle ); addElement ( scmEle, "connection", scm ); addElement ( scmEle, "developerConnection", scm ); addElement ( scmEle, "url", scmUrl ); }
Example #29
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private IInstallableUnit findBest ( final Set<IInstallableUnit> candidates ) { if ( candidates.isEmpty () ) { return null; } return candidates.iterator ().next (); }
Example #30
Source File: Processor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
private void makePom ( final MavenReference ref, final Path versionBase, final Set<MavenDependency> deps, final IInstallableUnit iu ) throws Exception { final Document doc = this.documentBuilder.newDocument (); final Element project = doc.createElementNS ( "http://maven.apache.org/POM/4.0.0", "project" ); project.setAttributeNS ( "http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" ); doc.appendChild ( project ); addElement ( project, "modelVersion", "4.0.0" ); addElement ( project, "groupId", ref.getGroupId () ); addElement ( project, "artifactId", ref.getArtifactId () ); addElement ( project, "version", ref.getVersion () ); addElement ( project, "url", makeProjectUrl ( iu ) ); // name and description String name = iu.getProperty ( "org.eclipse.equinox.p2.name", null ); if ( name == null ) { name = String.format ( "%s:%s", ref.getGroupId (), ref.getArtifactId () ); } String description = iu.getProperty ( "org.eclipse.equinox.p2.description", null ); if ( description == null ) { description = name; } addElement ( project, "name", name ); addElement ( project, "description", description ); addOrganization ( project ); addDevelopers ( project ); // license final List<License> lics = this.licenseProvider.getLicenses ( iu ); if ( lics != null ) { addLicense ( project, lics ); } else if ( ref.getArtifactId ().startsWith ( "org.eclipse." ) ) { addLicense ( project, singletonList ( EPL ) ); } else { this.errors.add ( String.format ( "%s: no license information", ref ) ); } makeScm ( iu, doc, project, versionBase, ref ); if ( !deps.isEmpty () ) { final Element depsEle = doc.createElement ( "dependencies" ); project.appendChild ( depsEle ); for ( final MavenDependency dep : deps ) { final Element depEle = doc.createElement ( "dependency" ); depsEle.appendChild ( depEle ); addElement ( depEle, "groupId", dep.getGroupId () ); addElement ( depEle, "artifactId", dep.getArtifactId () ); addElement ( depEle, "version", dep.getVersion () ); if ( dep.isOptional () ) { addElement ( depEle, "optional", "true" ); } } } final Path pomFile = versionBase.resolve ( ref.getArtifactId () + "-" + ref.getVersion () + ".pom" ); saveXml ( doc, pomFile ); makeChecksum ( "MD5", pomFile, versionBase.resolve ( ref.getArtifactId () + "-" + ref.getVersion () + ".pom.md5" ) ); makeChecksum ( "SHA1", pomFile, versionBase.resolve ( ref.getArtifactId () + "-" + ref.getVersion () + ".pom.sha1" ) ); addMetaDataVersion ( ref ); }