- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想要做的是将我的项目中预先创建的manifest.mf 文件与gradle 中的jar 任务动态创建的manifest 文件结合起来。
有什么办法可以做到这一点吗?目前我正在完全生成我的 list 文件:-
jar.doFirst {
manifest {
def requiredProjects = ''
configurations.compile.getAllDependencies().withType(ProjectDependency).each {dep->
def dependantProjects = dep.getDependencyProject()
def projects = project(dependantProjects.path).libsDir.list().findAll{it.endsWith('.jar')}
projects.removeAll(projects.findAll{it.endsWith('test.jar')})
def requiredProject = projects.join(' ')
requiredProjects += requiredProject.replaceAll(/ /,'%20') + ' '
logger.info 'Required Project: ' + requiredProject
}
logger.info 'Required requiredProjects: ' + requiredProjects
def compileFiles = configurations.compile.files{ it instanceof ExternalDependency }.collect {
File file = it
"lib/${file.name}"
}.join(' ')
def manifestPath = requiredProjects + compileFiles
logger.info 'Manifest: '+ manifestPath
attributes 'Class-Path': manifestPath
attributes 'Build-date': new Date();
attributes 'Application-Version': project.version
}
}
我知道我会有一个/META-INF/MANIFEST.MF 文件。
最初我使用 Gradle 的 OSGI 插件,但这似乎忽略了 list 文件并产生了巨大的困惑。
编辑
我对此进行了相当多的研究,感谢 carlo,我发现以下代码将允许我读取现有的 MANIFEST.MF:-
jar {
onlyIf { !compileJava.source.empty }
manifest {
// benutze das im Projekt vorliegende File, falls vorhanden:
def manif = "${projectDir}/META-INF/MANIFEST.MF"
if (new File(manif).exists()) {
from (manif) {
eachEntry { details ->
if (details.key == 'Bundle-Vendor') {
details.value = 'xyz GmbH'
}
}
}
}
else {
logger.info(project.name + " doesn't have a META-INF/MANIFEST.MF.")
manifest.attributes provider: xyz GmbH'
manifest.attributes project: project.name
manifest.attributes Build: new Date()
}
}
// copy if we have these:
from file ('plugin.xml')
from file ('plugin.properties')
into ('icons') { // if any ...
from fileTree('icons')
}
}
http://forums.gradle.org/gradle/topics/how_to_deal_with_eclipse_projects_and_manifest_files
我还发现了一个名为“wuff”的项目,旨在帮助使用 Gradle 构建 OSGi 项目。
最佳答案
最后我成功地使用以下代码得到了我想要的东西:-
jar.doFirst {
manifest {
def manifestFile = "${projectDir}/META-INF/MANIFEST.MF"
if ( new File( manifestFile ).exists() )
from ( manifestFile )
def requiredProjects = ''
configurations.compile.getAllDependencies().withType(ProjectDependency).each {dep->
def dependantProjects = dep.getDependencyProject()
def projects = project(dependantProjects.path).libsDir.list().findAll{it.endsWith('.jar')}
projects.removeAll(projects.findAll{it.endsWith('test.jar')})
def requiredProject = projects.join(' ')
requiredProjects += requiredProject.replaceAll(/ /,'%20') + ' '
logger.info 'Required Project: ' + requiredProject
}
logger.info 'Required requiredProjects: ' + requiredProjects
def compileFiles = configurations.compile.files{ it instanceof ExternalDependency }.collect {
File file = it
"lib/${file.name}"
}.join(' ')
def manifestPath = requiredProjects + compileFiles
logger.info 'Manifest: '+ manifestPath
attributes 'Class-Path': manifestPath
attributes 'Build-date': new Date();
attributes 'Application-Version': project.version
}
}
重要的几行是:-
def manifestFile = "${projectDir}/META-INF/MANIFEST.MF"
if ( new File( manifestFile ).exists() )
from ( manifestFile )
这允许我继承任何现有的/META-INF/MANIFEST.MF 文件,并且还包括由 gradle 动态管理的类路径依赖项。
关于Gradle list .MF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26636534/
使用maven得到编译好的*.war文件,其中包含: - META-INF - - MANIFEST.MF - WEB-INF - - classes - - lib - - web.xml 使用 j
我有一个 Android 应用程序,它使用 actionbarsherlock和库下的下一个 jar 文件夹: android-support-v4.jar gson-2.2.4.jar libGoo
我想要做的是将我的项目中预先创建的manifest.mf 文件与gradle 中的jar 任务动态创建的manifest 文件结合起来。 有什么办法可以做到这一点吗?目前我正在完全生成我的 list
我正在尝试读取 war 文件中的 MANIFEST.MF。我正在使用 Eclipse。 InputStream inputStream = getClass().getClassLoader().ge
我正在尝试使用MediaFoundation将ID3D11Texture2D编码为mp4。下面是我当前的代码。 初始化接收器编写器 private int InitializeSinkWriter(S
我正在使用sbt-assembly创建一个可运行的jar,但是我的应用程序崩溃了,因为jai imageio从MANIFEST.MF文件中加载了供应商名称。如果我从以下位置手动编辑META-INF/M
我正在尝试按照教程“ http://crunchify.com/how-to-build-restful-service-with-java-using-jax-rs-and-jersey/”中的说明
使用 Build.scala 将自定义键值对添加到 MANIFEST.MF 似乎不起作用。这是我的代码: import sbt._ import Keys._ import java.util.Dat
Clojure 程序如何找到自己的 MANIFEST.MF(假设它打包在 JAR 文件中)。 我试图从我的“-main”函数中执行此操作,但我找不到在以下代码中使用的类: (.getValue
我有一个从 JAR 文件运行的 Java 桌面应用程序,使用 MANIFEST.MF 文件,如下所示: list 版本:1.0主类:myMainClass启动画面图像:splashImage_en.j
我正在尝试从 file.war 内部读取 MANIFEST.MF 文件。它位于 META-INF 文件夹内。我有这段代码,但我收到空指针异常。请指教?谢谢! String warurl = "http
在不知道主类名称的情况下这可能吗?特别是我在应用程序启动时希望在信息电子邮件中发送的实现版本属性之后。我知道访问它的唯一方法需要知道我想要访问其信息的包或 jar 文件的名称;我不知道如何简单地通过寻
我收到以下 Tomcat 错误: 'Publishing to Tomcat v8.5 Server at localhost...' has encountered a problem. Publi
我有一个问题,因为我想把动态数据放在我的侧边菜单中我正在使用 [MFSideMenu] 和 Xcode Version 8.2.1 for ios 10.2.1 我创建了一个 SideMenuView
我正在向 Maven 中的 MANIFEST.MF 添加条目,如 maven-jar-plugin true
我一直在尝试运行一个 jar 文件 - 我们称它为 test.jar - 它在 Unix 系统上使用 Sybase jconn3.jar。 我创建了一个包含以下内容的 MANIFEST.MF 文件:
Java JAR 中的 MANIFEST.MF 文件是否有任何超出 JAR specification 的约定? ?我可能想要包括的有趣信息是:构建日期和其他构建信息、SVN 修订版,也许是描述。我还
是否有任何可用的工具可以从 jar 中获取 manifest.mf 文件并很好地显示内容? 特别是在使用 OSGi bundle 时,Export-Package 和 Import-Package 条
我试图从 MANIFEST.MF 文件中获取一些属性,但它们返回 null。 list Manifest-Version: 1.0 Archiver-Version: Plexus Archiver
我想使用 Frame Rate convertor DSP在我的媒体基金会应用程序中。我正在使用“SourceReader”来读取视频文件。谁能告诉我在何处以及如何将 DMO 与 MF 集成以获得帧速
我是一名优秀的程序员,十分优秀!