Crafter 3 Gradle bundle error - gradle

I am using Crafter 3.0.2 and trying to create deployable bundles through the gradle tooling provided by the craftercms project.
When executing gradlew build deploy bundle -Pcrafter.profile=true, I received the error message:
FAILURE: Build failed with an exception.
* Where:
Build file 'build.gradle' line: 774
* What went wrong:
Execution failed for task ':zipauthoring'.
> archive's size exceeds the limit of 4GByte.
The gradle suggestion following the error above is to enable zip64. So I added zip64 true to the build.gradle pack method's tasks.create("zip${envName}", Zip.class) {, and the bundle task completed successfully.
However, this approach seemed a little invasive. What is the proper procedure for producing a Crafter 3 bundle with profile enabled? If zip64 is to be used for the authoring bundle, is there a command line option that can be provided instead of editing build.gradle? Alternatively, is there a mechanism for creating only the tar.gz archive (which does not appear to have the 4gb file limitation) instead of the zip archive?

There is a ticket now to allow the users to select the bundle they want: https://github.com/craftercms/craftercms/issues/1669
I've never seen a bundle exceed 600MB, you're pushing up against 4GB which is very unusual. While adding 64bit will help it push on, there might be another issue at play here.

Related

java/spring-boot/gradle Wrong Entrypoint in image built with pack and paketobuildpacks/builder:base

I have a really simple java spring-boot gradle application.
When I build an image from source with:
pack build testapp:0.0.1 --builder paketobuildpacks/builder:base
and try to run it with docker I get the following error:
ERROR: failed to launch: determine start command: when there is no default process a command is required.
The generated Entrypoint in this image is "/cnb/lifecycle/launcher".
When I inspect the image with pack inspect-image there are no processes.
I tried this with different java spring-boot gradle applications. When I use the "bootBuildImage" gradle task, it does nearly the same but uses the pre-build .jar-file and the resulting image works. The generated Entrypoint in this image is "/cnb/process/web" and pack inspect-image shows three processes.
Any ideas?
I can't see your build output, but it sounds like you're hitting a known issue. If this is not your problem, please include the full output of running pack build.
Onto the issue. By default, Spring Boot Gradle projects will build both an executable and non-executable JAR. Because this produces two JAR files, it presently confuses the buildpacks.
There are a couple of solutions:
Tell Gradle to not build the non-executable JAR. The buildpack requires the executable JAR. You can do this by adding the following to your build.gradle file:
jar {
enabled = false
}
This is the solution we have used in the Paketo buildpack samples.
If you don't want to make the change suggested in #1, then you can add the following argument to pack build: -e BP_GRADLE_BUILT_ARTIFACT=build/libs/<your-jar>.jar. For ex: -e BP_GRADLE_BUILT_ARTIFACT=build/libs/demo-0.0.1-SNAPSHOT.jar. You can use glob-style pattern matching here, but you need to make sure that what you enter does not match *-plain.jar. That will be the non-executable JAR that gets built by default.
This option just simply tells the Gradle buildpack more specifically what the JAR file to pass along to subsequent buildpacks.
We also have an open issue that should help to mitigate this problem. When the executable-jar buildpack gains support for multiple JARs, it'll be less likely that you'll need to set this. Essentially, this fill will add support so the executable-jar buildpack can inspect and detect an executable JAR, which would allow it to throw out the -plain.jar file since it's not executable.

Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory

For some unknown reason, whenever I run gradle clean build after I start my notebook it works as expected. When I try for the second time, I always get
Unable to delete directory 'C:\_d\mycompany\WSs\demo\build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main\com\mybank
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main\com
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\test\com
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\test
- C:\_d\mycompany\WSs\demo\build\classes\kotlin
- C:\_d\mycompany\WSs\demo\build\classes
- C:\_d\mycompany\WSs\demo\build\generated\source\kapt
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin\main
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin\test
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin
- C:\_d\mycompany\WSs\demo\build\generated\source
- C:\_d\mycompany\WSs\demo\build\generated
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\inputs
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\jvm\kotlin
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\jvm
- and more ...
New files were found. This might happen because a process is still writing to the target directory.
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin
I found someone failing quite similar problem but using Android Studio/Ubuntu (I am using IntelliJ Community/Windows 10): other question
I tried carefully all recommendations and none of them fixed my issue. I only get it working back if I restart my Windows and just work one time.
Some of the recommendations are:
1 - Close the studio and go to the path the issue is located at and delete the folder there.
I tried close IntelliJ and I can't delete the folder straight
2 - File > Settings > Build, Execution, Deployment > Instant Run > Uncheck this Check box (Enable Instant Run to hot swap code)
There is no such optional in my IntelliJ
IntelliJ IDEA 2020.2.3 (Community Edition)
Build #IC-202.7660.26, built on October 6, 2020
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1963M
Cores: 8
Non-Bundled Plugins: Lombook Plugin, org.jetbrains.kotlin
3 - gradlew clean
Same issue
4 - right-click on the directory, click properties on the context menu that will appear, then uncheck the "Read Only" attribute. After that, click the "Apply" to apply changes.
I am administrator but I couldn't change such folder attribute.
5 - Running android studio as administrator in windows worked for me.
Same issue
Here are my build.gradle
plugins {
id "org.jetbrains.kotlin.jvm" version "1.4.10"
id "org.jetbrains.kotlin.kapt" version "1.4.10"
id "org.jetbrains.kotlin.plugin.allopen" version "1.4.10"
id "com.github.johnrengelman.shadow" version "6.1.0"
id "io.micronaut.application" version '1.0.5'
id "com.gorylenko.gradle-git-properties" version "2.2.2"
}
version "0.1"
group "com.mybank"
repositories {
mavenCentral()
jcenter()
}
micronaut {
runtime "netty"
testRuntime "junit5"
processing {
incremental true
annotations "com.mybank.*"
}
}
dependencies {
implementation("io.micronaut:micronaut-validation")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("javax.annotation:javax.annotation-api")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-management")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.sql:micronaut-hibernate-jpa")
runtimeOnly("com.h2database:h2")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
}
mainClassName = "com.mybank.ApplicationKt"
java {
sourceCompatibility = JavaVersion.toVersion('11')
}
compileKotlin {
kotlinOptions {
jvmTarget = '11'
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '11'
}
}
gradle.properties
micronautVersion=2.1.3
kotlinVersion=1.4.10
and the build folder seen in IntelliJ
*** edited
I didn't find how fix it. Now is happening with a project I have just cloned from micronaut
And I can't delete build folder although I am Windows administrator
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin> gradle clean build
> Task :clean FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':clean'.
> java.io.IOException: Unable to delete directory 'C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in
the target directory.
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp
* 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.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 13s
1 actionable task: 1 executed
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin> gradle stop
FAILURE: Build failed with an exception.
* What went wrong:
Task 'stop' not found in root project 'hello-world-kotlin'.
* Try:
Run gradle tasks to get a list of available tasks. 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.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin>
The problem is that you have multiple Gradle processes that are still holding locks to your files.
You can try running gradle --stop when this happens to stop any daemons that are running in the backgorund (this usually helps).
You can also check the state of your daemons by running gradle --status. For me this outputs:
No Gradle daemons are running.
Only Daemons for the current Gradle version are displayed.
See https://docs.gradle.org/6.5/userguide/gradle_daemon.html#sec:status
If you see something there it might be a problem.
Using --no-daemon and --no-parallel might help, but they would just hide the underlying problem.
In my case when this happened I realized that I had processes running in the background because of tests never finishing. Check all your threading and/or coroutine usage for unclosed / unfinished processes.
One other case when this happened to me is when I was using ProcessBuilder to start another Java process and it didn't exit.
Just rename the " build " folder.
In my case, I experienced this error after I ran a Gradle command as the root user in Linux.
After switching back to a regular user, Gradle gave me the above error. When I tried to remove the build directory using rm -rf build/, I received a "Permission denied" error. You can solve this problem by removing the build directory as the root user.
For me the files where under a different user and the group and the permissions were not sufficient to write to the files of the directory in question.
Try checking who the user of the project files are with ls -al
If the project and the sub directories and files are under a different user. You can run sudo chown -R [new_owner] [project_folder_name] The flag -R here recursively changes owner for the sub files and sub dirs.
You can also add additional permissions to the group (if the user belongs to the group) or even change the group (if the user does not belong to the group). The basic idea is giving the user enough permission (rwx) to use files.
In Windows 10 Kill all Java TM instances by running this command on command prompt :
TASKKILL /F /IM java.exe
Or you delete your app installed on your phone and reinstall it again.This solved my problem
As I have faced similar kinds of errors during the flutter app development, I have figured out which process is blocking the running app. So I have just ended Open JDK from the Process list and then retried running the app without debug mode and it's working. The thing I learned here is that we have multiple development environments running in the background so we have to determine which process is blocking others.
Delete build folder in this path : your project\app . Then rebuild project.
If you are running windows 10, Go to task manager and end the following task
.......................
Java Platform SE binary
There might be more than one above mentioned task just end all of them and rebuild works
I went to my file system and deleted the file manually. Restarted my android

Can't upgrade to gradle 6.6 because of "prefix string too short"

I'm trying to upgrade an existing project from gradle 6.5.1 to 6.6.
But when I build, it fails with an error:
Successfully started process 'Gradle build daemon'
An attempt to start the daemon took 1.116 secs.
The client will now receive all logging from the daemon (pid: 122). The daemon log file: /home/****/.gradle/daemon/6.6/daemon-122.out.log
Starting build in new daemon [memory: 519.0 MB]
Using 1 worker leases.
Starting Build
Compiling initialization script '/home/****/agent/workspace/Enrich_build_PR-41#tmp/artifactory/init-artifactory449129576487257952gradle' using SubsetScriptTransformer.
FAILURE: Build failed with an exception.
* What went wrong:
Failed to create Jar file /home/****/.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok.
> Prefix string too short
Running with --debug, the only thing that looks relevant is:
020-10-05T16:38:54.631+0000 [DEBUG] [org.gradle.internal.component.model.LoggingAttributeMatchingExplanationBuilder] Selected match ok from candidates [ok] for {org.gradle.dependency.bundling=external, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}
Which seems like an internal gradle issue. How can I fix or avoid this error?
(I also tried 6.6.1 and have the same problem)
It happens when I run "./gradlew help" as well, so it shouldn't be related to my build config.
The stacktrace looks like:
* Exception is:
org.gradle.api.GradleException: Failed to create Jar file /home/****/.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok.
at org.gradle.internal.classpath.ClasspathBuilder.jar(ClasspathBuilder.java:47)
at org.gradle.internal.classpath.InstrumentingClasspathFileTransformer.transform(InstrumentingClasspathFileTransformer.java:76)
at org.gradle.internal.classpath.InstrumentingClasspathFileTransformer.transform(InstrumentingClasspathFileTransformer.java:70)
at org.gradle.internal.classpath.DefaultCachedClasspathTransformer$TransformFile.lambda$schedule$0(DefaultCachedClasspathTransformer.java:261)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.IllegalArgumentException: Prefix string too short
at org.gradle.internal.classpath.ClasspathBuilder.buildJar(ClasspathBuilder.java:53)
at org.gradle.internal.classpath.ClasspathBuilder.jar(ClasspathBuilder.java:45)
... 6 more
Your issue seems to be related to artifactory plugin
Check https://github.com/jfrog/jenkins-artifactory-plugin/issues/349
Quick Fix
Recommend to downgrade to Gradle 6.5 to resolve the issue.
Further Details / Possible Cause
While I don't know the root cause of why this happens, I get the same 'Prefix string too short' error, in Gradle 6.6.1.
And in particular, this is my exact error message, from a Mac:
Failed to create Jar file /Users/****/.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok.
Since the 'prefix' error came from Java, I looked at my Java install thinking that might be the problem. In my case Java was many versions behind, so I upgraded to 8u261 however that didn't seem to change anything.
For how it starts in our case:
User kicks off Jenkins job for Gradle
Jenkins job fails specifically for being unable to create the file in the cache directory. And the number actually is the same each time for the cache too; it's always '.gradle/caches/jars-8/8535adf040d7c5fdb7fd6bc28bb0ef3f/ok' and not a different number. So it's almost like that is statically set from somewhere.
So focusing on that error, I came across this similar-ish prefix error, for a Java issue. While this doesn't fully answer the issue we see, it does help explain why it could be a 'legitimate' error as it thinks the file name is less than 3 characters.
https://stackoverflow.com/a/48806741/14403001
So it feels like it's interpreting the end of that string as being the file name. Namely it might think that ok at the end of the path is actually a filename, and being less than 3 characters it sends the 'Prefix string too short' error. Keep in mind this is speculation and I don't know if this is actually the cause or not.
We happened to have another Mac that was running Gradle 6.5 that was working fine with the exact same Jenkins job. So we downgraded from Gradle 6.6.1 to 6.5 to match the other and are back working like before.
Since we used Mac, Brew didn't actually have an older version to roll back to. So I was forced to uninstall gradle via brew, then follow the steps below to install and point to an older version of Gradle.
Hoping it's easier for you via yum/apt to downgrade than it was for myself.
https://gradle.org/install/#manually

Go CI does not recognize build file for gradle

I have setup GO CI pipeline for continuous integration in my project. I tried to add a project that is built using gradle. I tried a add gradle task for building my application.
While executing build it shows that
FAILURE: Build failed with an exception.
* What went wrong:
Task 'build' not found in root project 'Gradlepipelinejob'.
I tried to add defaultTasks 'clean', 'compile' to the parent build.gradle file. But still the same error exists. Someone pls help me in resolving this issue.
I think 'build' should be in Command section, rather than arguments. Even after that if it doesn't works, try executing build commands in the agent terminal(or any command prompt).This will let you figure out whether the error is in server or agent.
GO CI runs the command in the code checkout directory so please check if your gradle file is present or not in that directory

Liferay theme development using JBoss on Mac

I am creating liferay themes using JBoss on my Mac. In the process of creating a theme, when I execute ant deploy on my terminal, I am getting following errors:
Buildfile:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/g2y-b2b-theme/build.xml
[copy] Copying 1 file to /usr/share/ant/lib
BUILD FAILED
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/g2y-b2b-theme/build.xml:5:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/themes/build-common-theme.xml:7:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/build-common-plugin.xml:5:
The following error occurred while executing this line:
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/build-common.xml:68:
Failed to copy
/Users/saif/Desktop/Liferay/liferay-plugins-sdk-6.1.1/lib/ecj.jar to
/usr/share/ant/lib/ecj.jar due to java.io.FileNotFoundException
/usr/share/ant/lib/ecj.jar (Permission denied)
Total time: 0 seconds
Please help me to get rid of this and proceed further. What are the steps I should take in order to do this on a Mac? Please also tell me how to set up the environment variable of ANT on a Mac.
When ant builds your theme and requires ecj.jar (the eclipse compiler for java) it typically downloads it from some internet repository and places it in $ANT_HOME/lib. It seems your $ANT_HOME is usr/share/ant and you don't have write access to that directory. Either download it manually and place it there or open up the directory write permissions for one build (then close it again).
You'll only need to do this once: When ecj.jar is on the classpath for ant, it will just be used for eternity.

Resources