Search in sources :

Example 1 with DefaultMaven2OsgiConverter

use of com.liferay.ide.maven.core.util.DefaultMaven2OsgiConverter in project liferay-ide by liferay.

the class MavenBundlePluginProject method getSymbolicName.

@Override
public String getSymbolicName() throws CoreException {
    String bsn = ProjectUtil.getBundleSymbolicNameFromBND(getProject());
    if (!CoreUtil.empty(bsn)) {
        return bsn;
    }
    String retval = null;
    IProgressMonitor monitor = new NullProgressMonitor();
    IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(getProject(), monitor);
    MavenProject mavenProject = projectFacade.getMavenProject(monitor);
    Artifact artifact = mavenProject.getArtifact();
    File file = artifact.getFile();
    if (FileUtil.exists(file) && !file.getName().equals("classes")) {
        retval = new DefaultMaven2OsgiConverter().getBundleSymbolicName(artifact);
    } else {
        IProject project = getProject();
        // fallback to project name
        retval = project.getLocation().lastSegment();
    }
    return retval;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) DefaultMaven2OsgiConverter(com.liferay.ide.maven.core.util.DefaultMaven2OsgiConverter) File(java.io.File) IFile(org.eclipse.core.resources.IFile) Artifact(org.apache.maven.artifact.Artifact) IProject(org.eclipse.core.resources.IProject)

Aggregations

DefaultMaven2OsgiConverter (com.liferay.ide.maven.core.util.DefaultMaven2OsgiConverter)1 File (java.io.File)1 Artifact (org.apache.maven.artifact.Artifact)1 MavenProject (org.apache.maven.project.MavenProject)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)1