Diagnosing Gradle upgrades and buildSrc errors - gradle

I currently have an issue where, after trying to switch from Gradle 6.9.3 to 7.3.3, my :buildSrc:compileGroovy target fails with a NoClassDefFoundError on LoggingManagerInternal, which was a class removed in Gradle 7. The stack trace does not have appear to point to anywhere within the project code.
What would be the best way about diagnosing this issue, where it came from, and how it can be fixed?

In my project, it was using an old version of the gradle-docker-plugin, 'com.bmuschko:gradle-docker-plugin:6.7.0', but in a directory within my project called buildSrc. In buildSrc, there was another build.gradle file I was not aware of, which had an old version of the plugin calling the old gradle API.
My solution was to update that gradle plugin version from 4.6.2 to 6.7.0, and that got me to my next issue in the upgrade.

Related

Why would upgrading from Java 8 to Java 17 require me to use the maven-war-plugin?

I am upgrading a project from Java 8 to Java 17 and I am receiving the error (in a pom.xml file) "Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer". I have updated the other dependencies in the pom file as part of the upgrade process as well. I have seen in other stack overflow posts that say this could mean one should update the maven-war-plugin. The thing is, I am not currently using that plugin. When I add it, it does fix the issue, but I am just wondering why that would be.
I suspect the following happened.
When you build a WAR, then the Maven War Plugin is called implicitly (you can see that in the logs).
For some reason, the version was older than the newest available version (maybe a caching problem, maybe parent POM etc.). By explictly setting the version of the Maven War Plugin, this problem vanishes.

How to fix gradle eclipse plugin to use correct JRE when importing gradle project?

Currently, I can run ./gradlew eclipse and create the eclipse project and that works great in that it uses JavaSE-1.8. Unfortunately, I have 12 projects and don't really feel like loading each one at a time.
The issue though is when I use the gradle eclipse plugin and import the project, it decides to use JavaSE-1.7 which I did 'used' to use. I can't seem to find a quick setting in the gradle plugin, though it would be even nicer if I could just put the info in the build.gradle file for everyone to use.
The following code blew up in my face when I imported the project..
https://issues.gradle.org/browse/GRADLE-3100
Well, the .remove method blew up. Removing that resulted in ending up in 1.7 even though I put 1.8.
I am using gradle-2.11-bin.zip
UPDATE: I removed the '' replacing with single ' so that it doesn't throw an exception but still loads 1.7. To work around this issue, I load with gradle plugin and then run ./gradlew eclipse and then collapse all projects and using the shift key, I then select all projects and refresh and it moves to 1.8 (so the gradlew eclipse works while the gradle plugin doesn't :( they must be different code path).

Getting an error while executing goals from maven plugin flexmojos-maven-plugin

I get the below error while executing the default lifecycle 'clean install' from my maven project.
java.lang.String cannot be cast to org.apache.maven.lifecycle.mapping.LifecyclePhase
My code uses the flexmojos-maven-plugin. As per the jira thread https://issues.apache.org/jira/browse/MNG-5958 this issue has been resolved, but nowhere could I find how.
As per the solution I would have to update Lifecycle.java. Updating Lifecycle.java would mean updating maven-core.jar.
Will I have to go the extent of updating a standard jar which could impact many other files which are using this jar.
I am using maven 3.3.9 and java 8.
The problem is that the Maven guys changed quite a lot internally again with Maven 3.3.9 so currently you will have to use an older Maven version. I also doubt that I will be able to spare the time to address this in the future as Flexmojos has become more and more a beast to maintain. Therefore I am currently working on a completely new maven plugin which I am developing as part of the Apache flex project. For now I would suggest to use Maven 3.3.3 ... should work nicely with that.

Intellij Debugging picking up old version project files

I am debugging code in Intellij. I use maven to build the project and there are various versions of the project sitting in the local .m2 repository. Intellij keeps on picking the old version of the code from the previous snapshot of the project when I start debugging. How do I make IntelliJ debug the latest code from the local repository?
You can tell Intellij 2016 to ask you each time which source code to step through.
File->Settings->Debugger
Show alternative source switcher
Try removing .jar and .war files that contain your code from your ~/.m2/repository/
For me the issue is that I built something and it is now registered in Maven under what Maven considers a newer version, but isn't what I was currently working on. I compiled, say, version "2.1" to debug something and then went back to working on "sand-box-idea-SNAPSHOT". I keep thinking why isn't Intellij picking up my latest sand box change but it's because it's deferring to the Maven version 2.1 which Maven assumes is better than 'sand-box-SNAPSHOT'.
It may be that you have some plug-ins interfering with IntelliJ's build process. I know that the Google Protocol Buffers Plugin can cause my Intellij to be unable to detect dirty classes that need to be re-compiled.
I've met similar behavior, maybe it can help you :-)
I developed app (using maven) and during the time I change output packaging from jar to war. Maven repository than contained both versions, jar and war, because maven does not remove old jar when you change it. As project pointed to mvn repository, it still used old reference to jar but new version within war was updated.
I was really upset as maven compilation and tests worked fine but Idea used me old version. I've had rebuild idea project and it worked later fine.
I have seen this very recently after upgrading from IDEA 13 to IDEA 14. It seems like launching configurations created in IDEA 13 are no longer automatically triggering a mvn package prior to launch.
In order to fix this I manually added a mvn goal in the "Before Launch" dialog.

STS M2E 'Plugin execution not covered by lifecycle configuration" Error - Flex-Mojos

I am trying to write my pom.xml for a multimodal flex application. I have been using this resource as an example:
http://www.sonatype.com/books/mvnref-book/reference/flex-dev-sect-creating-with-archetype.html
I am using M2E v1.01 but I am faced with a number of 'Plugin execution not covered by lifecycle configuration" errors. As far as I can see - there are no m2E connectors available to resolve this and I have tried all the Maven advice I can find - to include:
Clean
Update dependencies
Update project configuration
The problem only occurs if the project is declared as swc or swf package. My next move to ask Eclipse to 'permanently mark goal as ignored' - which seems a little brash.
Any advice would be appreciated.
Thanks in advance.
With STS 2.8.0, we have upgraded m2eclipse to be version 1.0. However, this can cause a bit of trouble with existing projects. I wrote a blog on this a couple of months ago.
http://blog.springsource.org/2011/10/18/upgrading-maven-integration-for-springsource-tool-suite-2-8-0/
Essentially, the new architecture for m2eclipse requires that each maven plugin you use must be mapped to one Eclipse plugin to handle the plugin's execution inside of Eclipse. This obviously causes problems since not every maven plugin author has the knowledge or time to create also create and maintain an Eclipse plugin.
By marking the plugin as ignored, you are saying that the plugin should never be executed inside of Eclipse (implying that whenever you need it to be executed, you will do so from the command line). Once marked as ignored, you can then change it to execute, which means that it should always be executed whenever the associated lifecycle is performed in Eclipse. This may cause performance problems, and so only do it if you know the risks.
If all this is too much for you, then STS provides a downgrade option to revert to an older version of m2eclipse. Go to the Dashboard extensions page. Unfortunately, you will have to manually revert all changes to your .project and .classpath files (we provide an auto-upgrade mechanism, but not a downgrade mechanism...presumably everything is in version control).
Any questions or problems should be sent to the STS forums:
http://forum.springsource.org/forumdisplay.php?32-SpringSource-Tool-Suite
You can check this alpha connector "Flex Maven Integration for Flash Builder" on the eclipse marketplace: http://marketplace.eclipse.org/node/648556.

Resources