I have a Groovy application, I am using Gradle as my build tool. I have 2 seperate projects a Ratpack project with it's own build.gradle file and then a React project with it's own build.gradle file.
When I do ./gradlew run It builds my Ratpack project which in my Ratpacks build.gradle file has
compile project(':react-app')
In the dependencies closure.
Is there a way to just be able to run one of the projects for example ./gradlew runRatPack which stops the React project from being built?
If you can change the following line
compile project(':react-app') which states there is a Project Dependency to
compile name : 'react-app' - artifact dependency, then the project will try to pick the artifact from the repository instead of building the project.
Please let me know if the issue is addressed and this solves your issue.
Related
if I have created a spring Boot application using maven. Now I have to run the same codes in Gradle,So what all changes I have to make.
Here is the migration guide maven to gradle
A simple project can migrated by following chapter 3
3. Run an automatic conversion
install gradle to you system
run gradle init
Accordig to the same guide:
You’ll find that the new Gradle build includes the following:
All the custom repositories that are specified in the POM
Your external and inter-project dependencies
The appropriate plugins to build the project (limited to one or more of the Maven Publish, Java and War Plugins)
I have custom gradle plugin as a standalone project. I would like to use it in other project.
Suppose that plugin is not yet build. Is there any way how can I compile my plugin (in my other project) and add it on classpath to buildScript block all in one build.gradle of my other project ?
I am new to gradle so sorry if this is dumb question.
Failed to complete Gradle Execution
When I try to Sync Gradle with Project Files, the error mentioned below appears
Android Studio version that I am using is 3.0.1, Gradle Build 4.1-all.zip
FYI, I have already tried ->Build->Clean Project and Invalidate Cache & Restart and one more thing is that there is no error in my code.
Message Error:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
Error:Failed to complete Gradle execution.
Cause:
Operation org.gradle.tooling.internal.provider.events.DefaultOperationDescriptor#86028ba already available.
BUILD SUCCESSFUL in 8s
Information:1 error
Information:0 warnings
But When I try to Run on my Emulator
The error below appears
Message Error At Run Time
Information:Gradle tasks [:app:assembleDebug]
E:\Android Game App\app\build.gradle
Error:(1, 1) A problem occurred evaluating project ':Android Game App:app'.
Failed to apply plugin [id 'com.android.application']
Due to a limitation of Gradle new variant-aware dependency management, loading the Android Gradle plugin in different class loaders leads to a build error.
This can occur when the buildscript classpaths that contain the Android Gradle plugin in sub-projects, or included projects in the case of composite builds, are set differently.
To resolve this issue, add the Android Gradle plugin to only the buildscript classpath of the top-level build.gradle file.
In the case of composite builds, also make sure the build script classpaths that contain the Android Gradle plugin are identical across the main and included projects.
If you are using a version of Gradle that has fixed the issue, you can disable this check by setting android.enableBuildScriptClasspathCheck=false in the gradle.properties file.
To learn more about this issue, go to https://d.android.com/r/tools/buildscript-classpath-check.html.
Information:BUILD FAILED in 16s
Information:1 error
Information:0 warnings
Information:See complete output in console
Nothing found on Google! Any help would be highly encouraged???
The key to the problem is this line. Maybe due to a project.all in root build.gradle or you are using composite builds.
This can occur when the build script classpaths that contain the Android Gradle plugin in sub-projects,
or included projects in the case of composite builds, are set differently.
that mean in all yours build.gradle you have more than one this line
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:x.y.z"
}
}
what this means is that with the introduction of Android Gradle Plugin 3.Y.Z and the new way of handling dependencies,
if you mix in the same project 2 projects with different plugin version (one with a 2.3 and other with 3.0.1) you will get dragons while compiling.
And this error it's a way to force developer to check it and opt-out once detected and solved.
how to solve it, first ensure you don't use a android gradle plugin below 3.0.1 and use the new dependencies configurations, and add this property on every gradle.properties you have.
android.enableBuildScriptClasspathCheck=false
with that you can now compile
one example could be found at realm sample repo they use a allprojects block that include android gradle plugin on every module. and solve it adding previus gradle property at root gradle.properties
I have 3 gradle projects, projectA, projectB, projectC. All of which build a jar file named projectX-0.0.0.jar. On my jenkins server, all of these projects deploy these jars to my companies artifactory.
In projectA, I have multiple compile dependencies used throughout my entire project. Then in project B, I include project A by stating: compile group: 'com.company.projectName', name: 'projectA, version '0.0.0' So I can use these dependencies (i.e. slf4j) I do the same for projectC to include projectB dependencies, which in result includes projectA's dependencies.
This works great for our jenkins servers on deployment, after I have pushed the code to the server, however when trying to test locally I can not get the dependencies to update for testing my code.
I have tried:
Updating the gradle cache that downloads project A from artifactory with locally built project A jar. Located in C:/users/username/.gradle/caches/path-to-jar.
Removed the compile group: 'com.company.projectName', name: 'projectA, version '0.0.0' and replaced it with compile files('libs/projectA-0.0.0.jar'), placing projectA's jar within a lib folder in projectB
Using gradle offline mode in IntelliJ and repeating #1
Going offline completely on my pc and repeating #1
With all 4 attempts above I still have not been able to resolve dependencies declared in project A for project B.
My goal is to be able to update a compile,testCompile,runtime,etc. dependency in my projectA.gradle file, and then run my projects down my pipeline to ensure this update effects the dependencies in my project as I intended.
You need to update the .jar and .pom file within your gradle cache. The .jar file contains the source code while the pom contains the dependencies you brought in the previous project. Using a gradlew clean build install you can create the jar and the pom.
So to solve your problem, do a gradle build clean install on project-a. Grab the jar and pom from the build file generated and replace the project-a.jar and project-a.pom within the cache. Then do the same for project-b and you will see the changes in project-c after a gradle refresh.
Hi) when I compile the project are with gradle idea, I should get jar file...?
maybe in the folder dist...
The problem is that I get only two files start.sh and start.cmd
gradle idea doesn't compile the project. It creates project files (*.iws, *.ipr, *l.iml) for IDEA (the IDE from JetBrains). Likewise, there is gradle eclipse to create project files for the Eclipse IDE.
To create a Jar, you can do gradle jar or gradle build (assuming you have the java plugin applied). gradle tasks shows which tasks are available for a given project.
start.sh and start.cmd sound like they are coming from the application plugin. Are you using the application plugin?
The above poster is right that gradle idea simply creates the IntelliJ files that define your modules, src locations, etc. It does NOT compile the project.
Adding apply plugin: 'java' to your build.gradle will allow you to run gradle jar to generate a jar file.