该应用程序在 Eclipse 中运行良好。但我无法通过 gradle ( gradle clean build)构建应用程序
结构如下:
financial-calculator(家长)
libraryapiapi想要使用的类library
我父母的settings.gradle档案:
rootProject.name = 'financial-calculator'
include 'library'
include 'api'
rootProject.children.each { it.name = rootProject.name + '-' + it.name }
Run Code Online (Sandbox Code Playgroud)
父build.gradle文件:
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "o.s.b:spring-boot-gradle-plugin:${springBootVersion}"
}
}
allprojects {
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'
group = 'net.hemisoft.financial.calculator'
version = "0.1.0-SNAPSHOT"
}
subprojects {
apply …Run Code Online (Sandbox Code Playgroud) 我真的很想特别喜欢Gradle 5和新的Kotlin DSL的结合,但是我很难(很容易)获得一个非常,非常简单且通用的Gradle运行版本。
在Maven默认目录布局中以简单的Gradle构建(即DRY)的形式发布具有几个相互依赖的子模块的Java库,作为高质量的Maven工件/存储库。
因此:有一个根项目作为伞,该根项目定义并包含所有通用配置(实际上是所有依赖项除外)。
我将当前的“结果”移植到Github上的示例项目中,并且已经在Gradle论坛中提出了这个问题。
目前,我无法声明在中央构建中提供标准-sources和-javadoc工件的必要任务。
例如,在寻找基于Kotlin DSL的解决方案时会发现这三个“解决方案” 在多模块场景中都不起作用(更长):
/build.gradle.kts)完整示例参见Github:https : //github.com/bentolor/gradle-maven-multimodule-kotlindsl
subprojects {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
group = "de.bentolor.sampleproject"
version = "0.1.0"
repositories {
jcenter()
}
dependencies {
// Dependencies used in EVERY module
"compile"("commons-logging:commons-logging:1.2")
"testImplementation"("junit:junit:4.12")
}
tasks { …Run Code Online (Sandbox Code Playgroud) 我一直试图在类似的问题中找到这个问题的答案,但我仍然不知道是什么导致了它。
我有一个多模块 maven 项目,我正在尝试运行mvn install或者mvn package我收到以下错误
[信息] 应用程序 ..................................... ..... 成功 [1.025 秒]
[信息] 模块数据 ..................................... FAILURE [ 0.952 s]
[INFO] module-app ...................................... 跳过
[ERROR] 无法执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.1.RELEASE:repackage (repackage) on project project-data: 执行目标 org.springframework.boot:spring-boot 的重新打包-maven-plugin:2.1.1.RELEASE:repackage failed: Unable to find main class -> [Help 1]
该project-app模块在 src 文件夹中有一个 java 类,而该project-data模块没有主类。
父 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>project-data</module>
<module>project-app</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent …Run Code Online (Sandbox Code Playgroud) 我有一个多模块 Android gradle 项目。
project
|- app
|- module1
|- module2
Run Code Online (Sandbox Code Playgroud)
每个模块都包含单元测试,该app模块还包含仪表测试。我不想从模块中获取 xml 报告,而是将它们存储在一个地方,例如/build/tests/reports.
到目前为止我尝试实现的是将报告目录设置为此路径
android {
testOptions {
resultsDir "$rootDir/build/test/results"
reportDir "$rootDir/build/test/reports"
}
}
Run Code Online (Sandbox Code Playgroud)
我将其应用到了模块的所有 gradle 文件中。但这似乎只适用于仪器/connected测试报告。我怎样才能在单元测试中实现这一目标?
testing android unit-testing multi-module android-gradle-plugin
我目前正在学习 John Thompson 的 Spring 框架初学者到大师课程。我按照他的一步步程序在 Spring Boot 上为 Spring Pet Clinic 创建多模块 Maven 项目。当我单击根模块上的包时,它显示重新打包失败,无法找到主类。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
[错误] 无法在项目 pet-clinic-data 上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:repackage(重新打包):目标 org.springframework.boot:spring 的执行重新打包-boot-maven-plugin:2.1.6.RELEASE:重新打包失败:无法找到主类 -> [帮助 1]
java spring-mvc multi-module spring-boot spring-boot-maven-plugin
我有一个具有以下结构的 gradle 多项目:
\n\nroot\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 core-library\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 build.gradle\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 additional-feature-library\n\xe2\x94\x82 \xe2\x94\x82\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 entities\n\xe2\x94\x82 \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 build.gradle\n\xe2\x94\x82 \xe2\x94\x82\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 build.gradle\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 sample-android-app\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 build.gradle\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 build.gradle\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 settings.gradle\nRun Code Online (Sandbox Code Playgroud)\n\n设置.gradle:
\n\ninclude(":core-library")\ninclude(":additional-feature-library")\ninclude(":additional-feature-library:entities")\ninclude(":sample-android-app")\nRun Code Online (Sandbox Code Playgroud)\n\n附加功能库/build.gradle:
\n\nplugins {\n id("java-library")\n id("kotlin")\n id("maven-publish")\n}\n\ndependencies {\n implementation(project(":additional-feature-library:entities"))\n implementation(project(":core-library"))\n\n // ... other dependencies from maven\n}\n\npublishing {\n publications {\n maven(MavenPublication) {\n groupId = "com.example"\n artifactId = "additional-feature-library"\n version = "1.0.0"\n\n from components.java\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n当我执行任务additional-feature-library/publishToMavenLocal时,它会生成*.jar文件,其中包含来自additional-feature-library和POM的类,具有以下依赖项:
\n\n <dependencies>\n <dependency>\n <groupId>root.additional-feature-library</groupId>\n <artifactId>entities</artifactId>\n <version>unspecified</version>\n <scope>runtime</scope>\n </dependency>\n <dependency>\n <groupId>root</groupId>\n <artifactId>core-library</artifactId>\n <version>1.0.2</version>\n <scope>runtime</scope>\n </dependency>\nRun Code Online (Sandbox Code Playgroud)\n\n问题是这些依赖项不存在(实际上 …
我试图了解使用 Java 平台模块系统 (JPMS) 构建项目与使用 multi-poms 构建项目之间的区别。
主要区别是 JPMS 封装代码而多 pom 项目分离项目依赖关系?
我在谷歌上搜索过,但没有找到对差异的很好解释,但我看到模块这个词可以互换使用。
我想读取 settings.gradle 中的命令行参数,以便我可以仅添加那些包含我正在传递的命令行的子模块。
我们可以读取settings.gradle中的命令行参数吗?
我有一个依赖于几个模块的Web应用程序.所以为了构建它,我有一个主pom.xml文件.我想要这个pom文件做的是检查所有模块.下面是我的pom文件.
<executions>
<execution>
<id>check-out-project1</id>
<phase>generate-sources</phase>
<goals>
<goal>checkout</goal>
</goals>
<configuration>
<checkoutDirectory>${project.build.directory}/module1</checkoutDirectory>
<connectionUrl>scm:svn:svn://svnserver/svn/module1/trunk</connectionUrl>
<!--<developerConnection>scm:svn:svn://svnserver/svn/module1/trunk</developerConnection>!-->
<username>username</username>
<password>password</password>
</configuration>
</execution>
<execution>
<id>check-out-project2</id>
<phase>generate-sources</phase>
<goals>
<goal>checkout</goal>
</goals>
<configuration>
<checkoutDirectory>${project.build.directory}/module1</checkoutDirectory>
<connectionUrl>scm:svn:svn://svnserver/svn/module1/trunk</connectionUrl>
<username>username</username>
<password>password</password>
</configuration>
</execution>
</executions>
Run Code Online (Sandbox Code Playgroud)
我试过mvn scm:checkout 和mvn scm:checkout -check-out-project1但是它给我错误: 无法运行checkout命令:无法加载scm提供程序.您需要定义connectionUrl参数.
我不明白为什么会发生这种情况,因为我已经在pom文件中定义了connectionUrl参数,我希望得到的想法是将pom文件配置为能够同时签出多个项目.请让我知道我在这里做错了什么,在此先感谢.
两者之间有什么区别吗?
C:/dev/path/to/Project> mvn package -pl MyModule -am -s settings.xml
Run Code Online (Sandbox Code Playgroud)
和
C:/dev/path/to/Project/MyModule> mvn package -am -s ../settings.xml
Run Code Online (Sandbox Code Playgroud)
就我而言,这两项行动的结果应该是一样的.
然而,在每种情况下,行为似乎都不同:前者似乎更广泛; 后者更快结束 - 我正在努力理解为什么会这样.
multi-module ×10
java ×5
maven ×5
gradle ×4
android ×2
dependencies ×1
groovy ×1
java-module ×1
maven-3 ×1
pom.xml ×1
spring ×1
spring-boot ×1
spring-mvc ×1
testing ×1
unit-testing ×1