Environment:
JDK 17
Gradle 7.4.2
org.moditect.gradleplugin 1.0.0-rc.3
com.github.gmazzo.buildconfig 3.0.3
I try to use jPackager for creating application images. I encountered that jPackager cannot cope with packages that "just" define an automatic module name. So I want to use Moditect to modify the dependencies to avoid their automatic module name property. This seems to work quite well. However I get a circular dependency in Gradle as soon as I enable the buildconfig plugin at the same time.
FAILURE: Build failed with an exception.
* What went wrong:
Circular dependency between the following tasks:
:addDependenciesModuleInfo
+--- :generateModuleInfo
| \--- :jar
| \--- :classes
| \--- :compileJava
| \--- :addDependenciesModuleInfo (*)
\--- :jar (*)
(*) - details omitted (listed previously)
Is there any way of breaking/avoiding this circular dependency or is there no way but to choose other plugins?
import java.time.LocalDate
plugins {
id 'application'
id 'distribution'
id 'java'
id 'com.github.gmazzo.buildconfig' version "3.0.3"
id 'org.openjfx.javafxplugin' version '0.0.11'
id "org.panteleyev.jpackageplugin" version "1.3.1"
id "org.moditect.gradleplugin" version "1.0.0-rc3" // FIXME Creates circular dependency with buildconfig
}
group 'bayern.steinbrecher'
version '0.1'
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
sourceCompatibility = 17
targetCompatibility = 17
dependencies {
implementation "bayern.steinbrecher:CheckedElements:0.13-rc.10-SNAPSHOT"
implementation "bayern.steinbrecher:JavaUtility:0.18"
implementation 'bayern.steinbrecher:ScreenSwitcher:0.2.4'
implementation 'com.itextpdf:kernel:7.1.17'
implementation 'com.itextpdf:io:7.1.17'
implementation 'com.itextpdf:layout:7.1.17'
implementation 'org.jetbrains:annotations:22.0.0'
}
run {
main = "$moduleName/bayern.steinbrecher.woodpacker.WoodPacker"
}
buildConfig {
buildConfigField("String", "APP_NAME", "\"${project.name}\"")
buildConfigField("String", "APP_VERSION", "\"${project.version}\"")
buildConfigField("String", "APP_VERSION_NICKNAME", "\"Das Alpha-Tier\"")
buildConfigField("long", "BUILD_TIME", "${System.currentTimeMillis()}L")
packageName("bayern.steinbrecher.woodpacker")
}
tasks.register("copyInstallerDeps", Copy) {
from(configurations.runtimeClasspath)
into("$buildDir/installer/files")
}
tasks.register("copyInstallerJars", Copy) {
from(tasks.jar)
into("$buildDir/installer/files")
}
tasks.jpackage {
dependsOn("build", "copyInstallerDeps", "copyInstallerJars")
appName = "\"${project.name}\""
appVersion = "\"${project.version}\""
vendor = "StoneSoft"
copyright = "Copyright (c) ${LocalDate.now().getYear()} $vendor"
module = "$run.main"
modulePaths = file("$buildDir/installer/files").listFiles() as List<String>
destination = "$buildDir/installer"
windows {
icon = "imageTemplates/logo.ico"
winDirChooser = true
winMenu = true
}
}
Related
I intend to publish my modules in a nexus repository with the following steps.
first step:
Create a android-publications.gradle file and add the following contents to it
android-publications.gradle :
apply plugin: 'maven-publish'
ext.moduleVersion = "0.0.0"
def moduleGroupId = "team.techvida.framework"
def moduleRepoUrl = "http://url/repository/maven-releases/"
afterEvaluate {
publishing {
publications {
debug(MavenPublication) {
from components.debug
groupId = moduleGroupId
artifactId = "$project.name-debug"
version = moduleVersion
}
release(MavenPublication) {
from components.release
groupId = moduleGroupId
artifactId = project.name
version = moduleVersion
}
}
repositories {
maven {
name "nexus"
url moduleRepoUrl
allowInsecureProtocol = true
credentials {
username findProperty("nexusUsername")
password findProperty("nexusPassword")
}
}
}
}
}
Step two
Use it in all modules as follows:
core module =>
apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {
}
presentation module =>
apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {
}
Third step
Use in a module that uses other modules
di module =>
apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {
implementation(project(Modules.core))
implementation(project(Modules.imageLoading))
implementation(project(Modules.prettyLogger))
}
Note 1 : Publishing the second step modules is done successfully.
Step 4 (which leads to a compilation error)
Publish the third step module (di)
Received error:
What went wrong:
Could not determine the dependencies of task ':di:publishReleasePublicationToNexusRepository'.
> Publishing is not able to resolve a dependency on a project with multiple publications that have different coordi
nates.
Found the following publications in project ':image_loading':
- Maven publication 'debug' with coordinates team.techvida.framework:image_loading-debug:0.0.1
- Maven publication 'release' with coordinates team.techvida.framework:image_loading:0.0.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run
with --scan to get full insights.
Would you please tell me how to solve this problem?
I’m updating the gradle version of my application, it was with version 2.3 and I’m going to 6.7.1
I changed some things, of course, but this error I’m not able to resolve:
> Could not set unknown property 'testClassesDir' for task ':systemtestRun' of type org.gradle.api.tasks.testing.Test.
build.gradle:
task systemtestRun(type: Test) {
description 'run tests'
testClassesDir = sourceSets.systemtest.output.classesDirs
classpath = sourceSets.systemtest.runtimeClasspath + sourceSets.test.runtimeClasspath }
It should be testClassesDirs not testClassesDir:
tasks.register('systemtestRun', Test) {
description = 'Runs system tests.'
group = 'verification'
testClassesDirs = sourceSets.systemtest.output.classesDirs
classpath = sourceSets.systemtest.runtimeClasspath
}
I am trying to split my ANTLR4 grammar in multiple files so i can test them more easily, i am using gradle as a build tool in a java project.
Both grammar compile correctly by separate but when i add the import to my main grammar i get the next compilation error
error(110): kanekotic/specflow/rider/SpecflowFeature.g4:3:7: can't find or load grammar SpecflowScenario
the inherited grammar looks like:
grammar SpecflowScenario;
#header {
package kanekotic.specflow.rider;
}
scenario
: 'Scenario: ';
and the main grammar looks like:
grammar SpecflowFeature;
import SpecflowScenario;
#header {
package kanekotic.specflow.rider;
}
file returns [List<String> values]
#init { $values = new ArrayList<String>(); }
: 'Feature: ' EOF;
What am i doing wrong? is this not allowed?
edit:
the gradle.build looks like:
plugins {
id "org.jetbrains.intellij" version "0.1.10"
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'antlr'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
intellij {
version '143.2370.31'
pluginName 'Specflow Rider'
}
group 'kanekotic.specflow.rider'
version '0.1'
repositories {
mavenCentral()
jcenter()
}
dependencies {
antlr "org.antlr:antlr4:4.5"
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:2.+"
}
all the code as it is open sourced is in this next link: https://github.com/kanekotic/Specflow.Rider/tree/antlr4_multiple_grammar
The Antlr plugin uses src/main/antlr as lib directory by default. As the grammar file to include is in kanekotic/specflow/rider, use the following code in your gradle file to include this location:
generateGrammarSource {
arguments << "-lib" << "src/main/antlr/kanekotic/specflow/rider"
}
See also this gradle thread.
I am still trying to get my gradle script work, I have expolered all logs and it seems that there are some classes are missing. Here is message.
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':horizontalrecyclerview'.
Caused by: java.lang.NoClassDefFoundError: org/gradle/api/publication/maven/internal/DefaultMavenFactory
at org.gradle.api.plugins.AndroidMavenPlugin.apply(AndroidMavenPlugin.java:88)
at org.gradle.api.plugins.AndroidMavenPlugin.apply(AndroidMavenPlugin.java:57)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(Imper
Caused by: java.lang.ClassNotFoundException: org.gradle.api.publication.maven.internal.DefaultMavenFactory
... 51 more
Here is my build.gradle.
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "1.0.0"
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
def siteUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView' // Homepage URL of the library
def gitUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView.git' // Git repository URL
group = "com.github.crosp.horizontalrecyclerview" // Maven Group ID for the artifact
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jsoup:jsoup:1.8.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:21.0.3'
}
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
// Add your description here
name 'Android Horizontal Recycler View with Headerr'
description = 'Android Horizontal Recycler View with Header project for displaying horizontal list on Android '
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'crosp'
name 'Alexandr Crospenko'
email 'crosp#xakep.ru'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
// https://github.com/bintray/gradle-bintray-plugin
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
// it is the name that appears in bintray when logged
name = "crosp"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing'
}
// mavenCentralSync {
// sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
// user = properties.getProperty("bintray.oss.user") //OSS user token
// password = properties.getProperty("bintray.oss.password") //OSS user password
// close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
// }
}
}
}
Maybe someone already had such problem or know the way to solve it ? Please help, because I cannot get it work whole day already.
Thx in advance.
I am doing the same thing (upload my aar to bintray) and I have the same problem.
I am aware that it is occurred in gradle library, so I change my gradle verion from 2.4.0 to 2.2.1 by this way
File -> Project Structure (or trigger hotkey command + ;) -> click the Project in the left list in the dialog -> input 2.2.1 in the Gradle textedit box.
I solve this error by this way.Look for the note part in file README.md.
Hope this can help you.
ps:If you want to use gradle 2.4.0, you should config android-maven-plugin version to 1.3 in classpath in the project root build.gradle as :
com.github.dcendents:android-maven-gradle-plugin:1.3
Can't get the subproject dependencies in root build file. They isn't initialized for some reasons.
Is there a possibility to get list of dependencies from project1 for example inside root ?
Pls see copyToLib task. It should return values from dependencies section of project1, but actually it's not.
Gradle version is 2.0
Root
|
|-project1
| |-build.gradle
|-project2
| |-build.gradle
|-core1
| |-build.gradle
|-core2
| |-build.gradle
|-build.gradle
|-settings.gradle
settings.gradle
include 'project1','project2','core1','core2'
rootProject.name="Root"
project1:build.gradle
version = '0.1'
dependencies {
compile project(':core1'),
project(':core2'),
'org.springframework:spring-web:4.0.6.RELEASE'
}
root:build.gradle
subprojects{
apply plugin: 'java'
apply plugin: 'eclipse'
apply from: "${rootProject.projectDir}/eclipse.gradle"
sourceCompatibility = 1.7
repositories {
mavenCentral()
}
task copyToLib(type: Copy) {
def deps = project.configurations.compile.getAllDependencies().withType(ProjectDependency)
for ( dep in deps ) {
println dep.getDependencyProject().projectDir
}
}
build.dependsOn(copyToLib)
}
When project variable is used in subprojects it refers to the current project - in this particular case - root.
You need to remove adding the task from subprojects closure and add the following piece of code:
subprojects.each { p ->
configure(p) {
task copyToLib << {
def deps = p.configurations.compile.allDependencies.withType(ProjectDependency)
for ( dep in deps ) {
println dep.getDependencyProject().projectDir
}
}
p.build.dependsOn(copyToLib)
}
}
Have simplified the task (it's not of type Copy) - You need to differentiate task action from configuration.