2016-11-20 12 views
0

Eclipseプラグインを開発していますが、組み込みのAntビルド・ファイルを同梱して出荷する必要があります。私がプロジェクトを実行しているときに働いています。しかし、私がプラグインをエクスポートしていて、エクスポートされたプラグインを別のEclipseにデプロイすると、Antビルドファイルは生成されません。私の疑いのあることは、ランタイムでは、antビルドファイルのソースにアクセスしていないことです。どのように問題を解決するためのポインタ?ここでは、コードされていますカスタムEclipseプラグインで組み込みのファイルとフォルダーを作成するには

private void createAntFile(IProject project, Properties properties) throws  CoreException, IOException {   
    InputStream antFileInputStream =null;  
    try {   
     String antFileName = properties.getProperty("name.ant.file"); 
     String antFilePath = properties.getProperty("path.ant.file"); 
     IFile file = project.getFile(antFileName);   
     antFileInputStream = Activator.getDefault().getBundle().getEntry(antFilePath).openStream();   
     file.create(antFileInputStream, false, null); 
     antFileInputStream.close();   
    }finally{   
     if(antFileInputStream!=null){ 
      try { 
       antFileInputStream.close(); 
      } catch (IOException e) {     
       e.printStackTrace(); 
      } 
     } 
    } 
} 
name.ant.file=build.xml 
path.ant.file=src/weblogic/ant/build.xml 

ソースビルドファイル私はパスのsrc /のweblogic /アリ/ build.xmlの

編集中にハードコーディングしています:

はここのコードには、組み込みフォルダを作成:

private void createWeblogicTemplate(IProject project, Properties properties) throws IOException, CoreException {   
    String weblogicTemplateSourcePath = properties.getProperty("path.weblogic.template.source"); 
    Path path = new Path(weblogicTemplateSourcePath); 
    Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);   
    URL fileURL = FileLocator.find(bundle, path, null); 
    String filePath = FileLocator.resolve(fileURL).getPath(); 
    System.out.println(filePath); 
    File sourceFile = new File(filePath); 
    String weblogicTemplateTargetPath = properties.getProperty("path.weblogic.template.target"); 
    IFolder folder = project.getFolder(weblogicTemplateTargetPath); 
    copyFolder(sourceFile,folder,project,properties);   
} 

のSystem.out.println(filePathには)としてパスを印刷しているライン10 /C:/Users//Desktop/eclipse-rcp-luna-SR2-win32-x86_64/eclipse/../../../workspace-plugin/weblogic/resources/weblogictemplate/

したがって、ローカルその働き。しかし、私はいくつかの他の日食でpluinを展開するときに動作しません。任意のポインタどのように組み込みフォルダを作成するには?

答えて

1

src/weblogic/ant/ディレクトリがエクスポートされたプラグインjarに含まれると思われます。srcディレクトリは、通常、プラグインjarには含まれていません。

プラグインに含めるリソースを別のディレクトリ(たとえば、resources)に入れ、そのディレクトリをプラグインbuild.propertiesに含めて、エクスポートされたプラグインjarに含めます。

+0

build.xmlをresourcesフォルダに移動したところ、正常に動作しています。しかし、jdbcテンプレート、セキュリティフォルダなどのフォルダをリソースに追加する必要があります。これらのフォルダは作成されません。フォルダをコピーするために何か特別な処理をする必要がありますか? –

+0

コードではbuild.xmlファイルしか作成されていないため、必要なすべてのファイルとフォルダを作成するコードを記述する必要があります。 –

関連する問題