我有一个Spring Boot项目,需要使用Gradle将.ebextensions文件夹从我的存储库中复制到jar文件的根(顶级)文件夹中。如果它不在jar文件的根目录中,我注意到AWS Beanstalk不会选择.ebextensions文件夹下的nginx conf文件。
也就是说,这个文件夹当前在repo中:
src
build.gradle
gradlew.bat
gradlew
build
README
.ebextensions在我的build.gradle中,我有这样的代码:
jar {
from('.')
into("./.")
include '.ebextensions/**'
}但是,我发现.ebextensions文件夹最终将位于jar文件中的BOOT-INF/classes/下。它还将擦除所有其他类文件,否则这些文件将位于BOOT-INF/classes/下!
如何获得与BOOT-INF相同级别的目录?
.
..
BOOT-INF
WEB-INF
.ebextensions
<Rest of the source files here>谢谢!
附注:我也尝试过下面的另一种解决方案,但也不起作用:
task copyEbExtensions(type: Copy) {
from '.'
into { getDestDir() }
include '.ebextensions'
}P.S.#2另外,这是我的build.gradle,以防对您有帮助:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.7.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'oneyearafter'
version = '0.1.26'
}
task copyEbExtensions(type: Copy) {
from '.'
into { getDestDir() }
include '.ebextensions'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-devtools")
compile("org.springframework.boot:spring-boot-starter-web")
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
// tag::tests[]
compile("org.thymeleaf:thymeleaf-spring4")
compile("org.springframework.boot:spring-boot-starter-security")
// JPA Data (We are going to use Repositories, Entities, Hibernate, etc...)
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
// Use MySQL Connector-J
compile 'mysql:mysql-connector-java'
}
bootRun {
addResources = true
}发布于 2017-10-02 12:22:33
下面是我用于构建jar文件的自定义gradle函数。运行任务compileRunableJarFile编译jar文件。
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src/java'
}
resources {
srcDir 'src'
exclude 'src/java/**/*'
}
}
}
compileJava.dependsOn(processResources)
jar {
duplicatesStrategy = 'exclude'
manifest {
attributes 'Implementation-Title': title,
'Implementation-Version': version,
'Implementation-Vendor': vendor,
'Created-By': creator,
'Main-Class': mainClass,
'Manifest-Version': version,
'Manifest-Title': title,
'Application-Name': title,
'JPA-PersistenceUnits': persistenceUnit
}
}
//create a single Jar with all dependencies
task compileRunableJarFile(type: Jar, description: 'to create runable JAR.', group: 'compile') {
manifest {
attributes 'Implementation-Title': title,
'Implementation-Version': version,
'Implementation-Vendor': vendor,
'Created-By': creator,
'Main-Class': mainClass,
'Manifest-Version': version,
'Manifest-Title': title,
'Application-Name': title,
'JPA-PersistenceUnits': persistenceUnit
}
baseName = 'app_name_prefix-' + getCurrentTime()
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}https://stackoverflow.com/questions/46519102
复制相似问题