简体   繁体   English

用gradle添加eclipse项目facet

[英]Adding eclipse project facet with gradle

I have aa gradle script that sets up an eclipse project for me. 我有一个gradle脚本,为我设置了一个eclipse项目。 My project needs to have an extra project facet added in addition to the default ones. 除了默认项目之外,我的项目还需要添加额外的项目方面。 The documentation has the following example 该文档具有以下示例

eclipse {
  wtp {
    facet {
      //you can add some extra wtp facets; mandatory keys: 'name', 'version':
      facet name: 'someCoolFacet', version: '1.3'
    }
  }
}

I tried adding my own facet using the given example, but instead of the facet being added to the existing facets, it actually replaced all other facets thus being the only facet in the settings. 我尝试使用给定的示例添加我自己的facet,但不是将facet 添加到现有facet,它实际上替换了所有其他facet,因此是设置中唯一的facet。 Obviously, this is not what I intended. 显然,这不是我的意图。 Question is, how do I add an extra facet to the default facets? 问题是,如何在默认方面添加额外方面?

Edit: 编辑:

I want to create a script that configures an eclipse project to a folder that only contains the project structure of an eclipse project, but no configuration files (.classpath, .project, .settings/). 我想创建一个脚本,将eclipse项目配置到一个文件夹,该文件夹只包含eclipse项目的项目结构,但没有配置文件(.classpath,.project,.settings /)。 I'm trying to add Vaadin plugin for Eclipse facet to a Vaadin project. 我正在尝试将Eclipse facet的Vaadin插件添加到Vaadin项目中。 This is how my script looks like 这就是我的脚本的样子

subprojects {
    apply plugin: 'war'  
    apply plugin: 'eclipse-wtp'

    sourceCompatibility = 1.6  
    targetCompatibility = 1.6  
    webAppDirName = 'WebContent'  
    vaadinDir = webAppDirName+'/VAADIN'  

    eclipse {

        wtp {
            facet {         
              facet name: 'com.vaadin.integration.eclipse.core', version: '7.0'
            }
        }

    }

    // Source directories  
    sourceSets{  
        main{  
            java{  
                srcDir 'src'  
            }  
        }  
    }  


}

defaultTasks 'eclipse'

This is the resulting facet settings 这是生成的构面设置

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
    <installed facet="com.vaadin.integration.eclipse.core" version="7.0"/>
</faceted-project>

Without defining any custom facets, the resulting configuration is 在没有定义任何自定义构面的情况下,得到的配置是

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
    <fixed facet="jst.java"/>
    <fixed facet="jst.web"/>
    <installed facet="jst.web" version="2.4"/>
    <installed facet="jst.java" version="6.0"/>
</faceted-project>

As said, I'm all the facets to be in the settings :) 如上所述,我是设置中的所有方面:)

Modifying defaults (rather than overwriting them) can sometimes be tricky (it's not an easy problem for Gradle to solve), but you can try the following: 修改默认值(而不是覆盖它们)有时会很棘手(对于Gradle来说,这不是一个容易解决的问题),但您可以尝试以下方法:

facet {
    facets = facets
    facet name: 'com.vaadin.integration.eclipse.core', version: '7.0'
}

Alternatively, you could declare the default facets explicitly, along with your custom facet. 或者,您可以显式声明默认构面以及自定义构面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM