Gradle 创建Web项目
apply plugin: 'java' apply plugin: 'war' apply plugin: 'eclipse-wtp' apply plugin: 'maven' def projectName = "finance-site" version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.7 webAppDirName = 'WebContent' [compileJava, javadoc, compileTestJava]*.options*.encoding = 'UTF-8' //源码结构 sourceSets { main { java { srcDir 'src/main/java' } resources { srcDir 'src/main/resources' } } } //在线仓库 repositories { maven { url 'http://maven.oschina.net/content/groups/public/' } mavenCentral() } //项目依赖 dependencies { providedRuntime project(':core-service-interface') providedCompile 'javax.servlet:servlet-api:2.5' providedRuntime 'javax.servlet:jstl:1.2' providedRuntime 'org.freemarker:freemarker:2.3+' providedRuntime 'commons-fileupload:commons-fileupload:1.2.2' providedRuntime 'org.springframework:spring-webmvc:3.2.4.RELEASE' providedRuntime "org.springframework:spring-web:3.2.4.RELEASE" providedRuntime 'org.springframework:spring-context-support:3.2.4.RELEASE' testCompile('junit:junit:4.7') } //eclipse 配置 eclipse { wtp { contextPath = "WebContent" deployName = "finance" component { resource sourcePath: 'src/main/java', deployPath: '/WEB-INF/classes' resource sourcePath: 'WebContent', deployPath: '/' resource sourcePath: '/remote', deployPath: '/WEB-INF/classes' } } } uploadArchives { repositories { mavenDeployer { repository(url: "http://192.168.2.167:8888/nexus/content/repositories/snapshots/") { authentication(userName: "admin", password: "admin123") pom.groupId = "com.ff" pom.version = version pom.artifactId = projectName } } } } build.dependsOn uploadArchives /*-----------发布编码 --------------- */ task publishCode << { /*copy { from into } */ } /*-----------发布测试 --------------- */ task publishTest << { } /*-----------发布线上 --------------- */ task publishOnline << { }