List of usage examples for org.apache.maven.project MavenProject getGroupId
public String getGroupId()
From source file:org.sourcepit.maven.bootstrap.core.AbstractBootstrapper.java
License:Apache License
private Map<String, MavenProject> getProjectMap(List<MavenProject> projects) throws org.apache.maven.DuplicateProjectException { Map<String, MavenProject> index = new LinkedHashMap<String, MavenProject>(); Map<String, List<File>> collisions = new LinkedHashMap<String, List<File>>(); for (MavenProject project : projects) { String projectId = ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion());/* w ww . ja v a2s . com*/ MavenProject collision = index.get(projectId); if (collision == null) { index.put(projectId, project); } else { List<File> pomFiles = collisions.get(projectId); if (pomFiles == null) { pomFiles = new ArrayList<File>(Arrays.asList(collision.getFile(), project.getFile())); collisions.put(projectId, pomFiles); } else { pomFiles.add(project.getFile()); } } } if (!collisions.isEmpty()) { throw new org.apache.maven.DuplicateProjectException("Two or more projects in the reactor" + " have the same identifier, please make sure that <groupId>:<artifactId>:<version>" + " is unique for each project: " + collisions, collisions); } return index; }
From source file:org.sourcepit.tpmp.AbstractTargetPlatformMojo.java
License:Apache License
protected Artifact createPlatformArtifact(MavenProject project) { final Artifact platformArtifact = repositorySystem.createArtifactWithClassifier(project.getGroupId(), project.getArtifactId(), project.getVersion(), "zip", classifier); return platformArtifact; }
From source file:org.srcdeps.mvn.enforcer.SrcdepsEnforcer.java
License:Apache License
@Override public void beforeProjectLifecycleExecution(ProjectExecutionEvent event) throws LifecycleExecutionException { final MavenProject project = event.getProject(); log.info("srcdeps enforcer checks for violations in {}:{}", project.getGroupId(), project.getArtifactId()); final Maven maven = configurationProducer.getConfiguration().getMaven(); final List<MojoExecution> mojoExecutions = event.getExecutionPlan(); final List<String> goals = new ArrayList<>(mojoExecutions.size()); for (MojoExecution mojoExecution : mojoExecutions) { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); goals.add(mojoDescriptor.getFullGoalName()); goals.add(mojoDescriptor.getGoal()); }//from w w w . j av a 2 s . c om final List<String> profiles = new ArrayList<>(); final List<Profile> activeProfiles = project.getActiveProfiles(); for (Profile profile : activeProfiles) { final String id = profile.getId(); profiles.add(id); } final Properties props = new Properties(); props.putAll(project.getProperties()); props.putAll(System.getProperties()); String[] firstViolation = assertFailWithout(maven.getFailWithout(), goals, profiles, props); if (firstViolation == null) { firstViolation = assertFailWith(maven.getFailWith(), goals, profiles, props); } if (firstViolation != null) { /* check if there are srcdeps */ Artifact parent = project.getParentArtifact(); if (parent != null) { assertNotSrcdeps(parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), firstViolation); } DependencyManagement dm; List<Dependency> deps; if ((dm = project.getDependencyManagement()) != null && (deps = dm.getDependencies()) != null) { assertNotSrcdeps(deps, firstViolation); } if ((deps = project.getDependencies()) != null) { assertNotSrcdeps(deps, firstViolation); } } }
From source file:org.srcdeps.mvn.plugin.SrcdepsInitMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); org.srcdeps.core.GavSet.Builder gavSetBuilder = GavSet.builder() // .includes(includes) // .excludes(excludes);//from w w w . j a va2s . co m if (excludeSnapshots) { gavSetBuilder.excludeSnapshots(); } this.gavSet = gavSetBuilder.build(); log.info("Using includes and excludes [{}]", gavSet); log.info("Supported SCMs: {}", scms); if (skip || !multiModuleRootDir.equals(session.getCurrentProject().getBasedir())) { log.info(getClass().getSimpleName() + " skipped"); } else { Configuration.Builder config = Configuration.builder() // .configModelVersion(Configuration.getLatestConfigModelVersion()).commentBefore("") // .commentBefore("srcdeps.yaml - the srcdeps configuration file") // .commentBefore("") // .commentBefore( "The full srcdeps.yaml reference can be found under https://github.com/srcdeps/srcdeps-core/tree/master/doc/srcdeps.yaml") // .commentBefore("") // .commentBefore("This file was generated by the following command:") // .commentBefore("") // .commentBefore(" mvn org.srcdeps.mvn:srcdeps-maven-plugin:init") // .commentBefore("") // ; ScmRepositoryIndex index = new ScmRepositoryIndex(session, repoSession, repositorySystem, projectBuilder, scms); log.debug("Going over [{}] reactor projects", reactorProjects.size()); /* first add the reactor projects to seenGas so that they get ignored */ for (MavenProject project : reactorProjects) { index.ignoreGav(project.getGroupId(), project.getArtifactId(), project.getVersion()); } for (MavenProject project : reactorProjects) { final List<Dependency> dependencies = project.getDependencies(); log.info("Project [{}] has [{}] dependencies", project.getArtifactId(), dependencies == null ? 0 : dependencies.size()); if (dependencies != null) { for (Dependency dependency : dependencies) { final String g = dependency.getGroupId(); final String a = dependency.getArtifactId(); final String v = dependency.getVersion(); if (!"system".equals(dependency.getScope()) && gavSet.contains(g, a, v)) { /* Ignore system scope */ index.addGav(g, a, v, failOnUnresolvable); } } } final DependencyManagement dependencyManagement = project.getDependencyManagement(); if (dependencyManagement != null) { final List<Dependency> managedDeps = dependencyManagement.getDependencies(); if (managedDeps != null) { for (Dependency dependency : managedDeps) { final String g = dependency.getGroupId(); final String a = dependency.getArtifactId(); final String v = dependency.getVersion(); if (!"system".equals(dependency.getScope()) && gavSet.contains(g, a, v)) { /* Ignore system scope */ index.addGav(g, a, v, false); } } } } MavenProject parent = project.getParent(); if (parent != null) { final String g = parent.getGroupId(); final String a = parent.getArtifactId(); final String v = parent.getVersion(); if (gavSet.contains(g, a, v)) { index.addGav(g, a, v, failOnUnresolvable); } } } Map<String, Builder> repos = index.createSortedScmRepositoryMap(); if (repos.size() == 0) { /* add some dummy repo so that we do not write an empty srcdeps.yaml file */ ScmRepository.Builder dummyRepo = ScmRepository.builder() // .commentBefore( "FIXME: srcdeps-maven-plugin could not authomatically identify any SCM URLs for dependencies in this project") // .commentBefore( " and has added this dummy repository only as a starting point for you to proceed manually") // .id("org.my-group") // .selector("org.my-group") // .url("git:https://github.com/my-org/my-project.git") // ; repos.put(dummyRepo.getName(), dummyRepo); } config // .repositories(repos) // .accept(new OverrideVisitor(System.getProperties())) // .accept(new DefaultsAndInheritanceVisitor()) // ; final Path srcdepsYamlPath = multiModuleRootDir.toPath().resolve("srcdeps.yaml"); try { YamlWriterConfiguration yamlWriterConfiguration = YamlWriterConfiguration.builder().build(); try (Writer out = Files.newBufferedWriter(srcdepsYamlPath, Charset.forName(encoding))) { config.accept(new YamlWriterVisitor(out, yamlWriterConfiguration)); } } catch (IOException e) { throw new MojoExecutionException(String.format("Could not write [%s]", srcdepsYamlPath), e); } } }
From source file:org.talend.components.api.service.internal.ComponentServiceImpl.java
License:Open Source License
public Set<Dependency> getArtifactsDependencies(MavenProject project, MavenBooter booter, String... excludedScopes) throws DependencyCollectionException, org.eclipse.aether.resolution.DependencyResolutionException { DefaultArtifact pomArtifact = new DefaultArtifact(project.getGroupId(), project.getArtifactId(), project.getPackaging(), null, project.getVersion()); // check the cache if we already have computed the dependencies for this pom. if (dependenciesCache.containsKey(pomArtifact)) { return dependenciesCache.get(pomArtifact); }// ww w .j av a 2 s .c o m RepositorySystem repoSystem = booter.newRepositorySystem(); DefaultRepositorySystemSession repoSession = booter.newRepositorySystemSession(repoSystem); DependencySelector depFilter = new AndDependencySelector( new ScopeDependencySelector(null, Arrays.asList(excludedScopes)), new OptionalDependencySelector(), new ExclusionDependencySelector()); repoSession.setDependencySelector(depFilter); List<RemoteRepository> remoteRepos = booter.getRemoteRepositoriesWithAuthentification(repoSystem, repoSession); CollectRequest collectRequest = new CollectRequest(new Dependency(pomArtifact, "runtime"), remoteRepos); // collectRequest.setRequestContext(scope); CollectResult collectResult = repoSystem.collectDependencies(repoSession, collectRequest); DependencyNode root = collectResult.getRoot(); Set<Dependency> ret = new HashSet<>(); ret.add(root.getDependency()); flattenDeps(root, ret); dependenciesCache.put(pomArtifact, ret); return ret; }
From source file:org.universAAL.support.directives.checks.DependencyManagementCheckFix.java
License:Apache License
private Map<DependencyID, String> getActualVersions(MavenProject mavenProject2) { TreeMap<DependencyID, String> versionMap = new TreeMap<DependencyID, String>(); boolean containsSubPOMProjects = includesPOMSubProjects(mavenProject2); for (MavenProject mavenProject : reactorProjects) { if (mavenProject.getVersion() != null && (!mavenProject.getPackaging().equals("pom") || containsSubPOMProjects)) { // Check if its a pom, add it if not! versionMap.put(new DependencyID(mavenProject.getGroupId(), mavenProject.getArtifactId()), mavenProject.getVersion()); getLog().debug("added to ActualVersions: " + mavenProject.getGroupId() + ":" + mavenProject.getArtifactId() + ":" + mavenProject.getVersion()); }/*from w w w . ja va 2 s.c o m*/ } return versionMap; }
From source file:org.universAAL.support.directives.checks.MavenCoordinateCheck.java
License:Apache License
/** {@inheritDoc} */ public boolean check(MavenProject mavenProject, Log log) throws MojoExecutionException, MojoFailureException { String artifactIdMatchString = mavenProject.getProperties().getProperty(ARTIFACT_ID_MATCH_PROP, DEFAULT_MATCH);//from w w w .j ava 2s. co m String groupIdMatchString = mavenProject.getProperties().getProperty(GROUP_ID_MATCH_PROP, DEFAULT_MATCH); String nameMatchString = mavenProject.getProperties().getProperty(NAME_MATCH_PROP, DEFAULT_MATCH); String versionMatchString = mavenProject.getProperties().getProperty(VERSION_MATCH_PROP, DEFAULT_MATCH); Pattern pAId = Pattern.compile(artifactIdMatchString); Pattern pGId = Pattern.compile(groupIdMatchString); Pattern pVer = Pattern.compile(versionMatchString); Pattern pNam = Pattern.compile(nameMatchString); Matcher mAId = pAId.matcher(mavenProject.getArtifactId()); Matcher mGId = pGId.matcher(mavenProject.getGroupId()); Matcher mVer = pVer.matcher(mavenProject.getVersion()); Matcher mNam = pNam.matcher(mavenProject.getName()); StringBuffer message = new StringBuffer(); if (!mAId.find()) { message.append("ArtifactId: " + mavenProject.getArtifactId() + DOES_NOT_MATCH_CONVENTION + artifactIdMatchString + "\n"); } if (!mGId.find()) { message.append("GroupId: " + mavenProject.getGroupId() + DOES_NOT_MATCH_CONVENTION + groupIdMatchString + "\n"); } if (!mVer.find()) { message.append("Version: " + mavenProject.getVersion() + DOES_NOT_MATCH_CONVENTION + versionMatchString + "\n"); } if (!mNam.find()) { message.append("Artifact Name: " + mavenProject.getName() + DOES_NOT_MATCH_CONVENTION + nameMatchString + "\n"); } if (message.length() > 0) { throw new MojoFailureException(message.toString()); } Model pomFileModel = null; try { pomFileModel = PomWriter.readPOMFile(mavenProject); } catch (Exception e) { } if (!mavenProject.getPackaging().equals("pom") && pomFileModel != null && (pomFileModel.getProperties().containsKey(ARTIFACT_ID_MATCH_PROP) || pomFileModel.getProperties().containsKey(GROUP_ID_MATCH_PROP) || pomFileModel.getProperties().containsKey(VERSION_MATCH_PROP) || pomFileModel.getProperties().containsKey(NAME_MATCH_PROP))) { throw new MojoFailureException("This project has declared naming conventions when it shoudln't.\n" + "This is probably an attempt to skip this directive, SHAME ON YOU!"); } return true; }
From source file:org.universAAL.support.directives.checks.ParentGForgePropertyCheck.java
License:Apache License
public static boolean isParentRootPOM(MavenProject mavenProject2) { MavenProject parent = mavenProject2.getParent(); if (parent == null) return false; String parentID = parent.getArtifactId(); return (parent.getGroupId().equals(UAAL_GID) && parentID.endsWith(UAAL_AID)); }
From source file:org.universaal.tools.buildserviceapplication.actions.CreateLaunchConfigurationFile.java
License:Apache License
public ILaunchConfiguration createLaunchConfiguration() { try {// w w w. j a v a2 s .co m ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager .getLaunchConfigurationType("org.eclipse.pde.ui.EquinoxLauncher"); ILaunchConfigurationWorkingCopy wc = type.newInstance(null, getArtifactId()); wc.setAttribute("append.args", true); wc.setAttribute("automaticAdd", true); wc.setAttribute("automaticValidate", false); wc.setAttribute("bootstrap", ""); wc.setAttribute("checked", "[NONE]"); wc.setAttribute("clearConfig", false); wc.setAttribute("configLocation", "${workspace_loc}/rundir/" + getArtifactId()); wc.setAttribute("default", true); wc.setAttribute("default_auto_start", true); wc.setAttribute("default_start_level", 8); wc.setAttribute("includeOptional", true); wc.setAttribute("org.eclipse.debug.core.source_locator_id", "org.eclipse.pde.ui.launcher.PDESourceLookupDirector"); // wc.setAttribute( // "org.eclipse.debug.core.source_locator_memento", // "<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/mw.bus.context/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/mw.bus.model/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/mw.bus.service/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/mw.data.representation/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/mw.data.serialization/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/ont.lighting/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/ont.phWorld/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/smp.lighting.client/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;folder nest=&quot;false&quot; path=&quot;/smp.lighting.server/src/main/java&quot;/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.folder"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "); wc.setAttribute("includeOptional", true); wc.setAttribute("org.eclipse.jdt.launching.JRE_CONTAINER", "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"); wc.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS", "-console --obrRepositories=http://depot.universaal.org/nexus/content/repositories/snapshots/repository.xml,http://depot.universaal.org/nexus/content/repositories/releases/repository.xml,http://bundles.osgi.org/obr/browse?_xml=1&amp;cmd=repository --org.ops4j.pax.url.mvn.repositories=+http://depot.universaal.org/nexus/content/groups/public,http://depot.universaal.org/nexus/content/repositories/snapshots@snapshots@noreleases --log=DEBUG"); wc.setAttribute("org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER", "org.eclipse.pde.ui.workbenchClasspathProvider"); wc.setAttribute("org.eclipse.jdt.launching.VM_ARGUMENTS", "-Dosgi.noShutdown=true -Dfelix.log.level=4 -Dorg.universAAL.middleware.peer.is_coordinator=true -Dorg.universAAL.middleware.peer.member_of=urn:org.universAAL.aal_space:test_env -Dbundles.configuration.location=${workspace_loc}/rundir/confadmin"); wc.setAttribute("includeOptional", true); wc.setAttribute("org.eclipse.jdt.launching.WORKING_DIRECTORY", "${workspace_loc}/rundir/" + getSelectedMavenProject().getArtifactId()); wc.setAttribute("org.ops4j.pax.cursor.hotDeployment", false); wc.setAttribute("org.ops4j.pax.cursor.logLevel", "DEBUG"); wc.setAttribute("org.ops4j.pax.cursor.overwrite", false); wc.setAttribute("org.ops4j.pax.cursor.overwriteSystemBundles", false); wc.setAttribute("org.ops4j.pax.cursor.overwriteUserBundles", false); ArrayList classpath = new ArrayList(); classpath.add("obr"); wc.setAttribute("org.ops4j.pax.cursor.profiles", classpath); List<Dependency> deps = getProjectDependencies(); Map map = new HashMap(); map.put("mvn:org.apache.felix/org.apache.felix.configadmin/1.2.4", "true@true@2@false"); Dependency dep = getDependency("mw.acl.interfaces"); if (dep == null) { map.put("mvn:org.universAAL.middleware/mw.acl.interfaces", "true@true@2@false"); } else { map.put("mvn:org.universAAL.middleware/mw.acl.interfaces/" + dep.getVersion(), "true@true@2@false"); deps.remove(getDependency("mw.acl.interfaces")); } dep = getDependency("mw.bus.context"); if (dep == null) { map.put("mvn:org.universAAL.middleware/mw.bus.context", "true@true@4@true"); } else { map.put("mvn:org.universAAL.middleware/mw.bus.context/" + dep.getVersion(), "true@true@4@true"); deps.remove(getDependency("mw.bus.context")); } dep = getDependency("mw.bus.model"); if (dep == null) { map.put("mvn:org.universAAL.middleware/mw.bus.model", "true@true@3@true"); } else { map.put("mvn:org.universAAL.middleware/mw.bus.model/" + dep.getVersion(), "true@true@3@true"); deps.remove(getDependency("mw.bus.model")); } dep = getDependency("mw.bus.service"); if (dep == null) { map.put("mvn:org.universAAL.middleware/mw.bus.service", "true@true@4@true"); } else { map.put("mvn:org.universAAL.middleware/mw.bus.service/" + dep.getVersion(), "true@true@4@true"); deps.remove(getDependency("mw.bus.service")); } dep = getDependency("mw.data.representation"); if (dep == null) { map.put("mvn:org.universAAL.middleware/mw.data.representation", "true@true@4@true"); } else { map.put("mvn:org.universAAL.middleware/mw.data.representation/" + dep.getVersion(), "true@true@4@true"); deps.remove(getDependency("mw.data.representation")); } dep = getDependency("mw.data.serialization"); if (dep == null) { map.put("mvn:org.universAAL.middleware/mw.data.serialization", "true@true@4@true"); } else { map.put("mvn:org.universAAL.middleware/mw.data.serialization/" + dep.getVersion(), "true@true@4@true"); deps.remove(getDependency("mw.data.serialization")); } List<Dependency> ontDep = getGroupDependencies("org.universAAL.ontology"); for (int i = 0; i < ontDep.size(); i++) { map.put("mvn:org.universAAL.ontology/" + ontDep.get(i).getArtifactId() + "/" + ontDep.get(i).getVersion(), "true@true@5@false"); deps.remove(getDependency(ontDep.get(i).getArtifactId())); } for (int i = 0; i < deps.size(); i++) { if (deps.get(i).getGroupId().startsWith("org.universAAL.")) { map.put("mvn:" + deps.get(i).getGroupId() + "/" + deps.get(i).getArtifactId() + "/" + deps.get(i).getVersion(), "true@true@4@true"); } } // map.put("mvn:org.universAAL.ontology/ont.lighting", // "true@true@5@false"); // map.put("mvn:org.universAAL.ontology/ont.phWorld", // "true@true@5@false"); MavenProject mavenProject = getSelectedMavenProject(); map.put("mvn:" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId() + "/" + mavenProject.getVersion(), "true@false@7@true"); map.put("wrap:mvn:java3d/j3d-core/1.3.1", "true@true@2@false"); map.put("wrap:mvn:java3d/vecmath/1.3.1", "true@true@2@false"); map.put("wrap:mvn:jp.go.ipa/jgcl/1.0", "true@true@2@false"); map.put("wrap:mvn:org.bouncycastle/jce.jdk13/144", "true@true@2@false"); map.put("wrap:mvn:org.ops4j.pax.confman/pax-confman-propsloader/0.2.2", "true@true@3@false"); map.put("wrap:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.0", "true@true@2@false"); map.put("wrap:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.0", "true@true@3@false"); map.put("wrap:mvn:org.osgi/osgi_R4_compendium/1.0", "true@true@2@false"); wc.setAttribute("org.ops4j.pax.cursor.provisionItems", map); deps = getProjectDependencies(); classpath = new ArrayList(); classpath.add("--overwrite=false"); classpath.add("--overwriteUserBundles=false"); classpath.add("--overwriteSystemBundles=false"); classpath.add("--hotDeployment=false"); classpath.add("--log=DEBUG"); classpath.add("--profiles=obr"); classpath.add("mvn:org.apache.felix/org.apache.felix.configadmin/1.2.4@2"); dep = getDependency("mw.acl.interfaces"); if (dep == null) { classpath.add("mvn:org.universAAL.middleware/mw.acl.interfaces@2"); } else { classpath.add("mvn:org.universAAL.middleware/mw.acl.interfaces/" + dep.getVersion() + "@2"); deps.remove(getDependency("mw.acl.interfaces")); } classpath.add("wrap:mvn:jp.go.ipa/jgcl/1.0@2"); classpath.add("wrap:mvn:java3d/vecmath/1.3.1@2"); classpath.add("wrap:mvn:org.bouncycastle/jce.jdk13/144@2"); classpath.add("wrap:mvn:java3d/j3d-core/1.3.1@2"); classpath.add("wrap:mvn:org.osgi/osgi_R4_compendium/1.0@2"); classpath.add("wrap:mvn:org.ops4j.pax.logging/pax-logging-api/1.6.3@2"); classpath.add("wrap:mvn:org.ops4j.pax.confman/pax-confman-propsloader/0.2.2@3"); classpath.add("wrap:mvn:org.ops4j.pax.logging/pax-logging-service/1.6.3@3"); dep = getDependency("mw.bus.model"); if (dep == null) { classpath.add("mvn:org.universAAL.middleware/mw.bus.model@3@update"); } else { classpath.add("mvn:org.universAAL.middleware/mw.bus.model/" + dep.getVersion() + "@3@update"); deps.remove(getDependency("mw.bus.model")); } dep = getDependency("mw.bus.context"); if (dep == null) { classpath.add("mvn:org.universAAL.middleware/mw.bus.context@4@update"); } else { classpath.add("mvn:org.universAAL.middleware/mw.bus.context/" + dep.getVersion() + "@4@update"); deps.remove(getDependency("mw.bus.context")); } dep = getDependency("mw.bus.service"); if (dep == null) { classpath.add("mvn:org.universAAL.middleware/mw.bus.service@4@update"); } else { classpath.add("mvn:org.universAAL.middleware/mw.bus.service/" + dep.getVersion() + "@4@update"); deps.remove(getDependency("mw.bus.service")); } dep = getDependency("mw.data.serialization"); if (dep == null) { classpath.add("mvn:org.universAAL.middleware/mw.data.serialization@4@update"); } else { classpath.add( "mvn:org.universAAL.middleware/mw.data.serialization/" + dep.getVersion() + "@4@update"); deps.remove(getDependency("mw.data.serialization")); } dep = getDependency("mw.data.representation"); if (dep == null) { classpath.add("mvn:org.universAAL.middleware/mw.data.representation@4@update"); } else { classpath.add( "mvn:org.universAAL.middleware/mw.data.representation/" + dep.getVersion() + "@4@update"); deps.remove(getDependency("mw.data.representation")); } for (int i = 0; i < ontDep.size(); i++) { classpath.add("mvn:org.universAAL.ontology/" + ontDep.get(i).getArtifactId() + "/" + ontDep.get(i).getVersion() + "@5"); deps.remove(getDependency(ontDep.get(i).getArtifactId())); } for (int i = 0; i < deps.size(); i++) { if (deps.get(i).getGroupId().startsWith("org.universAAL.")) { classpath.add("mvn:" + deps.get(i).getGroupId() + "/" + deps.get(i).getArtifactId() + "/" + deps.get(i).getVersion() + "@4@update"); } } classpath.add("mvn:" + mavenProject.getGroupId() + "/" + mavenProject.getArtifactId() + "/" + mavenProject.getVersion() + "@6@nostart@update"); wc.setAttribute("org.ops4j.pax.cursor.runArguments", classpath); wc.setAttribute("osgi_framework_id", "--platform=felix --version=1.4.0"); wc.setAttribute("pde.version", "3.3"); wc.setAttribute("show_selected_only", false); wc.setAttribute("tracing", false); wc.setAttribute("useCustomFeatures", false); wc.setAttribute("useDefaultConfigArea", false); ILaunchConfiguration config = wc.doSave(); return config; } catch (Exception ex) { ex.printStackTrace(); return null; } }
From source file:org.universaal.uaalpax.ui.WorkspaceProjectsBlock.java
License:Apache License
public BundleSet updateProjectList(BundleSet launchProjects) { IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IProject[] projects = myWorkspaceRoot.getProjects(); Set<BundleEntry> leftSet = new HashSet<BundleEntry>(projects.length), rightSet = new HashSet<BundleEntry>(projects.length); for (IProject p : projects) { // leftProjects.add(new ProjectURL(p.getName(), 5, true)); IResource pom = p.findMember("pom.xml"); if (pom != null && pom.exists() && pom.getType() == IResource.FILE) { IFile pomFile = (IFile) pom; try { Model model = null;/* www. j a va2 s . co m*/ MavenXpp3Reader mavenreader = new MavenXpp3Reader(); model = mavenreader.read(pomFile.getContents()); model.setPomFile(pomFile.getFullPath().toFile()); MavenProject project = new MavenProject(model); LaunchURL launchUrl = new LaunchURL("mvn:" + project.getGroupId() + "/" + project.getArtifactId() + "/" + project.getVersion()); BundleEntry pu = new BundleEntry(launchUrl, p.getName(), 12, true); leftSet.add(pu); } catch (CoreException e) { System.out.println("Failed to parse " + p.getName() + ": " + e); } catch (IOException e) { System.out.println("Failed to parse " + p.getName() + ": " + e); } catch (XmlPullParserException e) { System.out.println("Failed to parse " + p.getName() + ": " + e); } } } BundleSet remainingProjects = new BundleSet(launchProjects); // now all workspace projects are in leftTable // put items to right table if they are contained in launch config for (BundleEntry e : launchProjects) { try { String launchURL = e.getArtifactUrl().url; // check if this launch url corresponds to a project in workspace for (Iterator<BundleEntry> iter = leftSet.iterator(); iter.hasNext();) { BundleEntry pu = iter.next(); // startsWith ensures that the test passes if the version is not entered in launchUrl try { if (pu.getArtifactUrl().url.startsWith(launchURL)) { iter.remove(); rightSet.add(new BundleEntry(pu.getProjectName(), e.getLaunchUrl(), e.getOptions())); remainingProjects.remove(e); } } catch (UnknownBundleFormatException e1) { // should never happen since bundles from left list should always be maven bundles } } } catch (UnknownBundleFormatException e1) { // ignore launch bundle if not artifact } } leftTable.removeAll(); leftTable.addAll(leftSet); rightTable.removeAll(); rightTable.addAll(rightSet); return remainingProjects; }