2017-02-14 13 views
2

현재 프로그래밍 방식으로 생성 된 Xtend 클래스를 컴파일하려고합니다. 이것은 모두 Eclipse 플러그인의 일부입니다. 이것은 내가하는 일입니다 :Xtend 클래스를 프로그래밍 방식으로 컴파일하는 것이 작동하지 않습니다.

  • Xtend 종속성을 프로그래밍 방식으로 대상 프로젝트에 추가 (작동).
  • 프로그래밍 방식으로 프로젝트에서 Xtend 클래스를 IProject.getFolder(), IFolder.getFile()IFile.create() (JDT API)으로 프로그래밍하여 만듭니다.
  • 결과로, 나는 이클립스 IDE에서 생성 된 클래스를 볼 수 있습니다, 지금 IProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());

와 함께 프로젝트를 컴파일 IProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());

  • 와 전체 프로젝트를 Resfreshing. 문제는 xtend-gen 폴더에 Xtend 클래스에 대해 생성 된 Java 클래스가 없다는 것입니다.

    Eclipse IDE에서 생성 된 Xtend 클래스 중 하나를 수동으로 열면 컴파일이 트리거됩니다. 이제는 Xtend 클래스에 대해 생성 된 Java 클래스를 볼 수 있습니다.

    하지만 프로그래밍 방식으로이 작업을 수행해야합니다. 하나의 Xtend 클래스를 수동으로 열지 않아도됩니다. 어떻게해야합니까? 여기에 어떤 문제가 있습니까? Xtend 컴파일을 실행하지 않는 이유는 무엇입니까?

  • 답변

    1

    제대로 프로젝트 설명을 업데이트하지 않은 것 같습니다. Xtext 빌더가 설정되지 않았습니다.

    내가 할 방법이를 지금 :

    private static void updateProjectDescription(IProject project) { 
        String builderName = "org.eclipse.xtext.ui.shared.xtextBuilder"; 
        String xtextNature = "org.eclipse.xtext.ui.shared.xtextNature"; 
        IProjectDescription description = null; 
        try { 
         description = project.getDescription(); 
        } catch (CoreException exception) { 
         exception.printStackTrace(); 
        } 
        // add xtext builder: 
        ICommand[] commands = description.getBuildSpec(); 
        ICommand command = description.newCommand(); 
        command.setBuilderName(builderName); 
        if (Arrays.asList(commands).contains(command)) { 
         logger.warn(".project already contains " + builderName); 
        } else { 
         ICommand[] newCommands = new ICommand[commands.length + 1]; 
         System.arraycopy(commands, 0, newCommands, 0, commands.length); 
         newCommands[commands.length] = command; 
         description.setBuildSpec(newCommands); 
        } 
        // Add xtext nature: 
        String[] natures = description.getNatureIds(); 
        if (Arrays.asList(natures).contains(xtextNature)) { 
         logger.warn(".project already contains " + xtextNature); 
        } else { 
         String[] newNatures = new String[natures.length + 1]; 
         System.arraycopy(natures, 0, newNatures, 0, natures.length); 
         newNatures[natures.length] = xtextNature; 
         description.setNatureIds(newNatures); 
        } 
        try { 
         project.setDescription(description, new ProgressMonitorAdapter(logger)); 
        } catch (CoreException exception) { 
         logger.fatal(exception); 
        } 
    }