Example usage for org.apache.maven.project MavenProject getVersion

List of usage examples for org.apache.maven.project MavenProject getVersion

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getVersion.

Prototype

public String getVersion() 

Source Link

Usage

From source file:org.wso2.developerstudio.eclipse.artifact.task.ui.wizard.TaskCreationWizard.java

License:Open Source License

public void updatePom() throws IOException, XmlPullParserException {
    File mavenProjectPomLocation = esbProject.getFile("pom.xml").getLocation().toFile();
    MavenProject mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    version = mavenProject.getVersion();

    // Skip changing the pom file if group ID and artifact ID are matched
    if (MavenUtils.checkOldPluginEntry(mavenProject, "org.wso2.maven", "wso2-esb-task-plugin")) {
        return;//from www . j  a v  a2  s.co  m
    }

    Plugin plugin = MavenUtils.createPluginEntry(mavenProject, "org.wso2.maven", "wso2-esb-task-plugin",
            ESBMavenConstants.WSO2_ESB_TASK_VERSION, true);
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.addGoal("pom-gen");
    pluginExecution.setPhase("process-resources");
    pluginExecution.setId("task");

    Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode();
    Xpp3Dom artifactLocationNode = MavenUtils.createXpp3Node(configurationNode, "artifactLocation");
    artifactLocationNode.setValue(".");
    Xpp3Dom typeListNode = MavenUtils.createXpp3Node(configurationNode, "typeList");
    typeListNode.setValue("${artifact.types}");
    pluginExecution.setConfiguration(configurationNode);
    plugin.addExecution(pluginExecution);
    MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
}

From source file:org.wso2.developerstudio.eclipse.artifact.template.wizards.TemplateProjectCreationWizard.java

License:Open Source License

public void updatePom() throws IOException, XmlPullParserException {
    File mavenProjectPomLocation = project.getFile("pom.xml").getLocation().toFile();
    MavenProject mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    version = mavenProject.getVersion();

    // Skip changing the pom file if group ID and artifact ID are matched
    if (MavenUtils.checkOldPluginEntry(mavenProject, "org.wso2.maven", "wso2-esb-template-plugin")) {
        return;/*from  ww w. j  a  va2s .c o  m*/
    }

    Plugin plugin = MavenUtils.createPluginEntry(mavenProject, "org.wso2.maven", "wso2-esb-template-plugin",
            ESBMavenConstants.WSO2_ESB_TEMPLATE_VERSION, true);
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.addGoal("pom-gen");
    pluginExecution.setPhase("process-resources");
    pluginExecution.setId("template");

    Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode();
    Xpp3Dom artifactLocationNode = MavenUtils.createXpp3Node(configurationNode, "artifactLocation");
    artifactLocationNode.setValue(".");
    Xpp3Dom typeListNode = MavenUtils.createXpp3Node(configurationNode, "typeList");
    typeListNode.setValue("${artifact.types}");
    pluginExecution.setConfiguration(configurationNode);
    plugin.addExecution(pluginExecution);
    MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
}

From source file:org.wso2.developerstudio.eclipse.distribution.project.export.CappArtifactsListProvider.java

License:Open Source License

public List<ListData> getArtifactsListForSingleArtifactProject(IProject project) throws Exception {
    MavenProject mavenProject = DistProjectUtils.getMavenProject(project);
    ArtifactTypeMapping artifactTypeMapping = new ArtifactTypeMapping();
    List<ListData> singleProjectArtifactAsAList = new ArrayList<ListData>();
    Dependency dependency = new Dependency();
    dependency.setArtifactId(mavenProject.getArtifactId());
    dependency.setGroupId(mavenProject.getGroupId());
    dependency.setVersion(mavenProject.getVersion());
    String cAppType = mavenProject.getModel().getPackaging();
    if (cAppType == null || !artifactTypeMapping.isValidArtifactType(cAppType)) {
        if (mavenProject.getModel().getProperties().containsKey("CApp.type")) {
            cAppType = (String) mavenProject.getModel().getProperties().get("CApp.type");
        }//  w  ww . j  ava 2s .  c o m
    }

    dependency.setType(artifactTypeMapping.getType(cAppType));
    ServerRoleMapping serverRoleMapping = new ServerRoleMapping();
    String serverRole = serverRoleMapping.getServerRole(cAppType);

    DependencyData dependencyData = new DependencyData();
    dependencyData.setDependency(dependency);
    dependencyData.setSelf(project);
    dependencyData.setCApptype(cAppType);
    dependencyData.setServerRole(getServerRole(serverRole));

    singleProjectArtifactAsAList
            .add(createListData(DistProjectUtils.getArtifactInfoAsString(dependency), dependencyData));
    return singleProjectArtifactAsAList;
}

From source file:org.wso2.developerstudio.eclipse.distribution.project.export.CarExportHandler.java

License:Open Source License

public List<IResource> exportArtifact(IProject project) throws Exception {
    List<IResource> exportResources = new ArrayList<IResource>();
    List<ArtifactData> artifactList = new ArrayList<ArtifactData>();
    Map<IProject, Map<String, IResource>> resourceProjectList = new HashMap<IProject, Map<String, IResource>>();
    IFile pomFileRes;/*from  ww  w .j a v  a  2  s .  c o  m*/
    File pomFile;
    MavenProject parentPrj;
    ArchiveManipulator archiveManipulator = new ArchiveManipulator();

    clearTarget(project);

    // Let's create a temp project
    File tempProject = createTempProject();

    File carResources = createTempDir(tempProject, "car_resources");
    pomFileRes = project.getFile(POM_FILE);
    if (!pomFileRes.exists()) {
        throw new Exception("not a valid carbon application project");
    }
    pomFile = pomFileRes.getLocation().toFile();

    ProjectList projectListProvider = new ProjectList();
    List<ListData> projectListData = projectListProvider.getListData(null, null);
    Map<String, DependencyData> projectList = new HashMap<String, DependencyData>();
    Map<String, String> serverRoleList = new HashMap<String, String>();
    for (ListData data : projectListData) {
        DependencyData dependencyData = (DependencyData) data.getData();
        projectList.put(DistProjectUtils.getArtifactInfoAsString(dependencyData.getDependency()),
                dependencyData);
    }

    parentPrj = MavenUtils.getMavenProject(pomFile);

    for (Dependency dependency : (List<Dependency>) parentPrj.getDependencies()) {
        String dependencyKey = DistProjectUtils.getArtifactInfoAsString(dependency);
        serverRoleList.put(dependencyKey, DistProjectUtils.getServerRole(parentPrj, dependency));
        if (projectList.containsKey(dependencyKey)) {
            DependencyData dependencyData = projectList.get(dependencyKey);
            Object parent = dependencyData.getParent();
            Object self = dependencyData.getSelf();
            String serverRole = serverRoleList.get(DistProjectUtils.getArtifactInfoAsString(dependency));
            dependencyData.setServerRole(serverRole.replaceAll("^capp/", ""));
            if (parent != null && self != null) { // multiple artifact
                if (parent instanceof IProject && self instanceof String) {
                    IFile file = ((IProject) parent).getFile((String) self);
                    if (file.exists()) {
                        ArtifactData artifactData = new ArtifactData();
                        artifactData.setDependencyData(dependencyData);
                        artifactData.setFile(distProjectUtils.getFileName(dependencyData));
                        artifactData.setResource((IResource) file);
                        artifactList.add(artifactData);
                    }
                }
            } else if (parent == null && self != null) { // artifacts as
                // single artifact archive
                DefaultArtifactExportHandler artifactExportHandler = new DefaultArtifactExportHandler();
                artifactExportHandler.exportArtifact(artifactList, null, null, dependencyData, null, self);

            } else if (parent != null && self == null) { // these are
                                                         // registry
                                                         // resources
                exportRegistryResourceArtifact(artifactList, resourceProjectList, dependencyData, parent);
            } else {
                log.error(
                        "unidentified artifact structure, cannot be exported as a deployable artifact for server "
                                + serverRole);
            }
        }
    }

    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMElement artifactsDocRoot = factory.createOMElement(new QName("artifacts"));
    OMElement artifactElt = factory.createOMElement(new QName("artifact"));
    artifactElt.addAttribute("name", parentPrj.getModel().getArtifactId(), null);
    artifactElt.addAttribute("version", parentPrj.getModel().getVersion(), null);
    artifactElt.addAttribute("type", "carbon/application", null);

    Collections.sort(artifactList);

    for (ArtifactData artifact : artifactList) {
        File artifactDir = new File(carResources, getArtifactDir(artifact.getDependencyData()));
        if (artifact.getResource() instanceof IFolder) {
            FileUtils.copyDirectory(artifact.getResource().getLocation().toFile(), artifactDir);
        } else if (artifact.getResource() instanceof IFile) {
            FileUtils.copy(artifact.getResource().getLocation().toFile(),
                    new File(artifactDir, artifact.getFile()));
        }
        artifactElt.addChild(createDependencyElement(factory, artifact));
        createArtifactXML(artifactDir, artifact);
    }

    artifactsDocRoot.addChild(artifactElt);
    File artifactsXml = new File(carResources, "artifacts.xml");
    XMLUtil.prettify(artifactsDocRoot, new FileOutputStream(artifactsXml));

    File tmpArchive = new File(tempProject,
            project.getName().concat("_").concat(parentPrj.getVersion()).concat(".car"));
    archiveManipulator.archiveDir(tmpArchive.toString(), carResources.toString());

    IFile carbonArchive = getTargetArchive(project, parentPrj.getVersion(), "car");
    FileUtils.copy(tmpArchive, carbonArchive.getLocation().toFile());
    exportResources.add((IResource) carbonArchive);
    clearTempDirInWorksapce(project.getName(), SPLIT_DIR_NAME);
    TempFileUtils.cleanUp();

    return exportResources;
}

From source file:org.wso2.developerstudio.eclipse.distribution.project.validator.ProjectList.java

License:Open Source License

public List<ListData> getListData(String modelProperty, ProjectDataModel model) {
    List<ListData> list = new ArrayList<ListData>();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IProject[] projects = root.getProjects();
    for (IProject project : projects) {
        try {//from   w  w  w.  j a va 2s.co  m
            if (project.isOpen()) {
                if (project.hasNature(Constants.AXIS2_PROJECT_NATURE)
                        || project.hasNature(Constants.BPEL_PROJECT_NATURE)
                        || project.hasNature(Constants.DS_PROJECT_NATURE)
                        || project.hasNature(Constants.DS_VALIDATOR_PROJECT_NATURE)
                        || project.hasNature(Constants.ESB_PROJECT_NATURE)
                        || project.hasNature(Constants.JAXWS_PROJECT_NATURE)
                        || project.hasNature(Constants.JAXRS_PROJECT_NATURE)
                        || project.hasNature(Constants.WEBAPP_PROJECT_NATURE)
                        || project.hasNature(Constants.GADGET_PROJECT_NATURE)
                        || project.hasNature(Constants.LIBRARY_PROJECT_NATURE)
                        || project.hasNature(Constants.MEDIATOR_PROJECT_NATURE)
                        || project.hasNature(Constants.REGISTRY_FILTER_PROJECT_NATURE)
                        || project.hasNature(Constants.REGISTRY_HANDLER_PROJECT_NATURE)
                        || project.hasNature(Constants.GENERAL_PROJECT_NATURE)
                        || project.hasNature(Constants.CARBON_UI_PROJECT_NATURE)
                        || project.hasNature(Constants.CEP_PROJECT_NATURE)
                        || project.hasNature(Constants.BRS_PROJECT_NATURE)
                        || project.hasNature(Constants.JAGGERY_NATURE)
                        || project.hasNature(Constants.SERVICE_META_PROJECT_NATURE)) {
                    try {
                        if (project.hasNature(Constants.ESB_PROJECT_NATURE)
                                || project.hasNature(Constants.GENERAL_PROJECT_NATURE)) {
                            IFile artifactXMLFile = project.getFile(Constants.ARTIFACT_XML);

                            MavenProject mavenProject = DistProjectUtils.getMavenProject(project);

                            if (artifactXMLFile.exists()) {
                                ESBProjectArtifact artifactXMLDoc = new ESBProjectArtifact();
                                try {
                                    artifactXMLDoc.fromFile(artifactXMLFile.getLocation().toFile());
                                    List<ESBArtifact> artifacts = artifactXMLDoc.getAllESBArtifacts();
                                    for (ESBArtifact artifact : artifacts) {
                                        Dependency dependency = new Dependency();
                                        dependency.setArtifactId(artifact.getName());
                                        if (artifact.getGroupId() != null
                                                && !artifact.getGroupId().trim().isEmpty()) {
                                            dependency.setGroupId(artifact.getGroupId());
                                        } else {
                                            dependency.setGroupId(mavenProject.getGroupId());
                                        }
                                        dependency.setVersion(artifact.getVersion());
                                        // dependency.setVersion(mavenProject.getModel().getVersion()); //referring parent version
                                        dependency.setType(ArtifactTypeMapping.getType(artifact.getType()));
                                        dependency.setScope(Artifact.SCOPE_SYSTEM);

                                        // Following artifact types should
                                        // be changed to common template
                                        // artifact type
                                        String artifactType;
                                        if ((Constants.SEQUENCE_TEMPLATE_TYPE.equals(artifact.getType()))
                                                || (Constants.ENDPOINT_TEMPLATE_TYPE
                                                        .equals(artifact.getType()))) {
                                            artifactType = Constants.COMMON_TEMPLATE_TYPE;
                                        } else {
                                            artifactType = artifact.getType();
                                        }

                                        // Target path for capp artifacts
                                        StringBuilder systemPathBuilder = new StringBuilder();
                                        systemPathBuilder.append(project.getLocation().toString());
                                        systemPathBuilder.append(File.separator);
                                        systemPathBuilder.append(Constants.ESB_PROJECT_TARGET_CAPP);
                                        String outputDirPath = systemPathBuilder.toString();

                                        // Post fix defines the target path
                                        String artifactPostFix = getArtifactPostFix(artifactType);

                                        // Generate system path for the
                                        // dependency
                                        systemPathBuilder = new StringBuilder();
                                        systemPathBuilder.append(outputDirPath);
                                        systemPathBuilder.append(File.separator);
                                        systemPathBuilder.append(artifactPostFix);
                                        systemPathBuilder.append(File.separator);
                                        systemPathBuilder.append(artifact.getName());
                                        systemPathBuilder.append(File.separator);
                                        systemPathBuilder.append(Constants.POM_FILE_NAME);
                                        systemPathBuilder.append(".");
                                        systemPathBuilder.append(Constants.POM_FILE_EXTENSION);
                                        dependency.setSystemPath(systemPathBuilder.toString());

                                        DependencyData dependencyData = new DependencyData();
                                        dependencyData.setDependency(dependency);
                                        dependencyData.setParent(project);
                                        dependencyData.setSelf(artifact.getFile());
                                        dependencyData.setCApptype(artifactType);
                                        dependencyData.setServerRole(
                                                Constants.CAPP_PREFIX + artifact.getServerRole());

                                        dependencyData.setServerRole("capp/" + artifact.getServerRole());
                                        list.add(createListData(DistProjectUtils.getArtifactInfoAsString(
                                                dependency, project.getName()), dependencyData));
                                    }
                                } catch (FactoryConfigurationError ignored) {
                                    // ignored
                                }
                            }
                        } else {
                            String cAppType = "";
                            MavenProject mavenProject = DistProjectUtils.getMavenProject(project);
                            Dependency dependency = new Dependency();
                            dependency.setArtifactId(mavenProject.getArtifactId());
                            dependency.setGroupId(mavenProject.getGroupId());
                            dependency.setVersion(mavenProject.getVersion());
                            cAppType = mavenProject.getModel().getPackaging();
                            if (cAppType == null || !ArtifactTypeMapping.isValidArtifactType(cAppType)) {
                                if (mavenProject.getModel().getProperties().containsKey("CApp.type")) {
                                    cAppType = (String) mavenProject.getModel().getProperties()
                                            .get("CApp.type");
                                }
                            }
                            dependency.setType(ArtifactTypeMapping.getType(cAppType));
                            String serverRole = ServerRoleMapping.getServerRole(cAppType);

                            DependencyData dependencyData = new DependencyData();
                            dependencyData.setDependency(dependency);
                            dependencyData.setSelf(project);
                            dependencyData.setCApptype(cAppType);

                            if (!"".equals(serverRole)) {
                                dependencyData.setServerRole("capp/" + serverRole);
                            } else {
                                dependencyData.setServerRole("capp/ApplicationServer");
                            }

                            list.add(createListData(DistProjectUtils.getArtifactInfoAsString(dependency),
                                    dependencyData));
                        }
                    } catch (Exception ignored) {
                        // ignored
                    }
                }
            }
        } catch (Exception e) {
            log.error("Error reading project list", e);
        }
    }
    return list;
}

From source file:org.wso2.developerstudio.eclipse.ds.capp.refactor.DataServiceDeleteParticipant.java

License:Open Source License

private Dependency getDependencyForTheProject(IProject project) throws Exception {

    MavenProject mavenProject = MavenUtils.getMavenProject(project.getFile("pom.xml").getLocation().toFile());
    Dependency dependency = new Dependency();
    if (mavenProject != null) {
        dependency.setGroupId(mavenProject.getGroupId() + ".dataservice");
        dependency.setArtifactId(mavenProject.getArtifactId());
        dependency.setVersion(mavenProject.getVersion());
    }//from www . jav  a 2  s  . c  o  m
    return dependency;
}

From source file:org.wso2.developerstudio.eclipse.esb.project.FileModificationManager.java

License:Open Source License

@Override
public void resourceChanged(IResourceChangeEvent event) {
    try {//  w  ww  .  java 2 s.c om
        event.getDelta().accept(new IResourceDeltaVisitor() {
            public boolean visit(final IResourceDelta delta) {

                final IResource resource = delta.getResource();
                if (resource.getType() == IResource.ROOT) {
                    return true;
                } else if (resource.getType() == IResource.PROJECT) {
                    try {
                        IProject iProject = (IProject) resource;
                        if (iProject != null && iProject.isOpen() && iProject.hasNature(ESB_PROJECT_NATURE)) {
                            return true;
                        }
                    } catch (CoreException e) {
                        log.error("Error while checking the project nature", e);
                        return false;
                    }
                    return false;
                } else if (resource.getType() == IResource.FILE) {
                    if (delta.getKind() == IResourceDelta.ADDED) {

                        Job job = new Job("update ArifactXML") {

                            @Override
                            protected IStatus run(IProgressMonitor monitor) {
                                try {
                                    if (resource instanceof IFile) {
                                        final IFile file = (IFile) resource;
                                        IProject iProject = file.getProject();
                                        if (file.getParent() instanceof IFolder) {
                                            IFolder folder = (IFolder) file.getParent();
                                            IPath location = file.getLocation();
                                            IPath removeLastSegments = location.removeLastSegments(2);
                                            String grandParentDir = removeLastSegments.lastSegment();

                                            if (SYNAPSE_CONFIG_DIR.equals(grandParentDir)) {

                                                String source = FileUtils
                                                        .getContentAsString(file.getLocationURI().toURL());
                                                Openable openable = ESBGraphicalEditor.getOpenable();
                                                ArtifactType artifactType = (ArtifactType) openable
                                                        .artifactTypeResolver(source);

                                                final String folderType = folder.getName();
                                                final String arifacLiteral = artifactType.getName()
                                                        .toLowerCase();

                                                if (folderType.startsWith(arifacLiteral)) {

                                                    File arifact = iProject.getFile(ARTIFACT_MEATADATA_FILE)
                                                            .getLocation().toFile();
                                                    ESBProjectArtifact artifact = new ESBProjectArtifact();
                                                    artifact.fromFile(arifact);
                                                    List<ESBArtifact> allESBArtifacts = artifact
                                                            .getAllESBArtifacts();
                                                    ESBArtifact esbTempartifact = null;
                                                    for (ESBArtifact esbartifact : allESBArtifacts) {
                                                        String name = esbartifact.getName() + ".xml";
                                                        if (name.equals(file.getName())) {
                                                            return Status.OK_STATUS;
                                                        }
                                                        esbTempartifact = esbartifact;
                                                    }

                                                    String version = "";
                                                    String type = COMMAN_NAME
                                                            + ESBProjectUtils.getType(folder.getName());
                                                    String groupId = "";
                                                    String name = file.getName().split("\\.")[0];

                                                    if (esbTempartifact == null) {
                                                        File pomLocation = iProject.getFile(POM).getLocation()
                                                                .toFile();
                                                        MavenProject mavenProject = MavenUtils
                                                                .getMavenProject(pomLocation);
                                                        version = mavenProject.getVersion();
                                                        groupId = mavenProject.getGroupId();
                                                    } else {
                                                        version = esbTempartifact.getVersion();
                                                        groupId = esbTempartifact.getGroupId();
                                                    }

                                                    ESBArtifact esbArtifact = new ESBArtifact();
                                                    esbArtifact.setName(name);
                                                    esbArtifact.setVersion(version);
                                                    esbArtifact.setType(type);
                                                    esbArtifact.setServerRole(ESB_SEVER_ROLE);
                                                    esbArtifact.setGroupId(groupId);
                                                    // Should not use file separator here
                                                    esbArtifact.setFile(FILE_PATH + folder.getName() + "/"
                                                            + file.getName());
                                                    artifact.addESBArtifact(esbArtifact);
                                                    artifact.toFile();
                                                } else {
                                                    IPath movedFromPath = delta.getMovedFromPath();
                                                    if (movedFromPath != null) {
                                                        Display.getDefault().syncExec(new Runnable() {

                                                            @Override
                                                            public void run() {

                                                                MessageDialog.openError(
                                                                        Display.getCurrent().getActiveShell(),
                                                                        "Error Move",
                                                                        "Cannot move due to invalid location");

                                                                try {
                                                                    IUndoContext workspaceContext = (IUndoContext) ResourcesPlugin
                                                                            .getWorkspace()
                                                                            .getAdapter(IUndoContext.class);
                                                                    OperationHistoryFactory
                                                                            .getOperationHistory()
                                                                            .undo(workspaceContext,
                                                                                    new NullProgressMonitor(),
                                                                                    null);

                                                                } catch (ExecutionException e) {
                                                                    log.error("Cannot undo last operation", e);
                                                                }

                                                            }
                                                        });
                                                    }
                                                }
                                            }
                                        }
                                    }
                                } catch (FactoryConfigurationError | Exception e) {
                                    log.error("Error while updating the arifactxml", e);
                                }
                                return Status.OK_STATUS;
                            }
                        };
                        job.schedule();
                        return true;
                    } else if (delta.getKind() == IResourceDelta.REMOVED) {

                        Job job = new Job("update ArifactXML") {

                            @Override
                            protected IStatus run(IProgressMonitor monitor) {
                                try {
                                    if (resource instanceof IFile) {
                                        IFile file = (IFile) resource;
                                        if (file.exists()) {
                                            IProject project = file.getProject();
                                            IPath location = file.getLocation();
                                            IPath removeLastSegments = location.removeLastSegments(2);
                                            String grandParentDir = removeLastSegments.lastSegment();

                                            if (SYNAPSE_CONFIG_DIR.equals(grandParentDir)) {
                                                File arifact = project.getFile(ARTIFACT_MEATADATA_FILE)
                                                        .getLocation().toFile();
                                                ESBProjectArtifact artifact = new ESBProjectArtifact();
                                                artifact.fromFile(arifact);
                                                List<ESBArtifact> allESBArtifacts = artifact
                                                        .getAllESBArtifacts();
                                                ESBArtifact removeNode = null;
                                                Iterator<ESBArtifact> iterator = allESBArtifacts.iterator();
                                                while (iterator.hasNext()) {
                                                    ESBArtifact esbartifact = iterator.next();
                                                    String name = esbartifact.getName() + ".xml";
                                                    if (name.equals(file.getName())) {
                                                        removeNode = esbartifact;
                                                        break;
                                                    }

                                                }
                                                if (removeNode != null) {
                                                    artifact.removeESBArtifact(removeNode);
                                                    artifact.toFile();
                                                }
                                            }
                                        }
                                    }
                                } catch (FactoryConfigurationError | Exception e) {
                                    log.error("Error while updating the arifactxml", e);
                                }
                                return Status.OK_STATUS;
                            }
                        };
                        job.schedule();
                        return true;
                    }

                    return false;
                }
                return true;

            }
        });

    } catch (CoreException e) {
        log.error("Error while updating the arifactxml", e);
    }

}

From source file:org.wso2.developerstudio.eclipse.general.project.refactor.RefactorUtils.java

License:Open Source License

public static Dependency getDependencyForTheProject(IProject project) {
    MavenProject mavenProject = getMavenProject(project);

    Dependency dependency = new Dependency();

    if (mavenProject != null) {
        dependency.setGroupId(mavenProject.getGroupId() + ".resource");
        dependency.setArtifactId(mavenProject.getArtifactId());
        dependency.setVersion(mavenProject.getVersion());
    }//w ww. ja  v a 2 s.  com
    return dependency;
}

From source file:org.wso2.developerstudio.eclipse.gmf.esb.diagram.edit.parts.SequenceEditPart.java

License:Open Source License

private void addSequenceToRegistryArtifactXML(String sequenceName, IProject currentProject) {

    GeneralProjectArtifact generalProjectArtifact = new GeneralProjectArtifact();
    try {//from  ww w  .ja  v a 2 s.  c  o  m
        generalProjectArtifact.fromFile(currentProject.getFile("artifact.xml").getLocation().toFile()); //$NON-NLS-1$
        File pomLocation = currentProject.getFile("pom.xml").getLocation().toFile(); //$NON-NLS-1$
        MavenProject mavenProject = MavenUtils.getMavenProject(pomLocation);
        RegistryArtifact artifact = new RegistryArtifact();
        artifact.setName(sequenceName);
        artifact.setVersion(mavenProject.getVersion());
        artifact.setType("registry/resource"); //$NON-NLS-1$
        artifact.setServerRole("GovernanceRegistry"); //$NON-NLS-1$
        artifact.setGroupId(mavenProject.getGroupId() + ".resource"); //$NON-NLS-1$

        RegistryElement item = new RegistryItem();
        ((RegistryItem) item).setFile(sequenceName + ".xml"); //$NON-NLS-1$
        ((RegistryItem) item).setPath("/_system/governance/sequences"); //$NON-NLS-1$
        ((RegistryItem) item).setMediaType("application/vnd.wso2.sequence"); //$NON-NLS-1$
        artifact.addRegistryElement(item);
        generalProjectArtifact.addArtifact(artifact);
        generalProjectArtifact.toFile();

    } catch (Exception e) {
        log.error("Error while updating Artifact.xml", e); //$NON-NLS-1$
    }
}

From source file:org.wso2.developerstudio.eclipse.maven.internal.executor.impl.MavenExecutorImpl.java

License:Open Source License

public boolean setMavenParent(File mavenProjectLocation, File parentMavenProjectLocation) throws Exception {
    if (parentMavenProjectLocation == null) {
        setMavenParent(mavenProjectLocation, (MavenProjectType) null);
    } else {/* www . j  ava2 s .c o  m*/
        File parentProjectPomFile = new File(parentMavenProjectLocation, "pom.xml");
        MavenProject parentProject = MavenUtils.getMavenProject(parentProjectPomFile);
        String relativeLocation = FileUtils.getRelativePath(parentMavenProjectLocation, mavenProjectLocation);
        if (!parentProject.getModules().contains(relativeLocation)) {
            parentProject.getModules().add(relativeLocation);
        }
        MavenUtils.saveMavenProject(parentProject, parentProjectPomFile);
        MavenProjectType parentMavenProject = new MavenProjectType(parentProject.getGroupId(),
                parentProject.getArtifactId(), parentProject.getVersion());
        String relativePath = FileUtils.getRelativePath(mavenProjectLocation, parentProjectPomFile)
                .replace('\\', '/');
        parentMavenProject.setRelativePath(relativePath);
        setMavenParent(mavenProjectLocation, parentMavenProject);
    }
    return true;
}