Importing Gradle project leaves entire project behind - gradle

I have a libgdx project that has multiple modules like 'core' and 'desktop' within the project root. I was missing the Gradle tab. I wanted to add new dependencies to the project and needed to sync the project.
Apparently reimporting is the way to fix that.
Issues:
Importing the project just gives me an empty project with a .gradle and .idea folder without any of my project.
Copying the projects manually just adds the modules as normal directories, the Gradle build fails.
Adding the modules through project structure adds them as separate project roots, the build fails again.
Errors:
Cause: invalid type code: 53
https://pastebin.com/d8VRbJp9
https://pastebin.com/hSzeW0ai
Build:
https://pastebin.com/BwkCJMaD

I noticed your build.gradle doesn't have any source setting going on.
The easiest way to remedy this is to create a new project using the setup tool (I personally prefer this one and then just copy your source files and assets across. After that, only change the build file to name the project etc. try not to fiddle with other things.
I am unsure as to whether this next method will work but you can try it. If you really want to keep your original project, try adding the following to the build.gradle under each specific project:
sourceSets.main.java.srcDirs 'src'
sourceSets.main.resources.srcDir 'assets'
So each project should look like:
project(":desktop") {
apply plugin: "java"
sourceSets.main.java.srcDirs 'src'
sourceSets.main.resources.srcDir 'assets'
...
}
If anyone tries this and it doesn't work, let me know and I'll remove it from the answer.

Related

Building open source dependencies using gradle

I really don't have much experience in developing let alone using build tools.
I was assigned a task to build dependencies locally and get the jar files.
say I have a list of deps (GAV) like this:-
1. org.jetbrains.kotlin:kotlin-stdlib:1.6.0-RC
2. com.auth0:java-jwt:3.18.2, etc
3. openapi4j:openapi-operation-validator:1.0.7, etc
So i was able to download the source code url from maven repository and source code from github programmatically, for example :-
org.jetbrains.kotlin:kotlin-stdlib:1.6.0-RC - https://github.com/JetBrains/kotlin
com.auth0:java-jwt:3.18.2 - https://github.com/auth0/java-jwt
openapi4j-openapi-operation-validator-1.0.7 https://github.com/openapi4j/openapi4j
but there are many build.gradle files in different directories, how do I know which directory should I move into before running the gradle build command.
Things I have already tried and failed:-
For deps like this openapi4j:openapi-operation-validator:1.0.7, i can directly go into the openapi-operation-validator folder in the Github repo (https://github.com/openapi4j/openapi4j ) and run the gradle build command, but not all projects are structured like that I guess?
For deps like this com.auth0:java-jwt:3.18.2, the artifactId (java-jwt
) is already present in the github path (https://github.com/auth0/java-jwt), so i can run the gradle build command on the root github repo.
From the spring guides , among all the Gradle.build files available I can check which file has:-
jar {
archiveBaseName = <artifactId>
archiveVersion = <version>
}
, then I can move to that dir and run Gradle build, but not all build.gradle files have this.
None of the above approaches are concrete, is there any other firm approach that I can use to tackle the problem?
Your approach is generally correct.
You need to find the source code in github/gitlab/wherever, read the readme file and try to build it with whatever build tool was used there.
This may or may not work.

How to configure Gradle module name in InteliJ IDEA

I have project with numerous of submodules located in different directories:
enter image description here
How you can see, the module name of IDEA (in []) differs from directory root. I've tried to modify it though Project Settings, but after gradle sync it returns to initial state.
Is it possible to configure Gradle to set module name according with directory name?
IDE takes the module name from the Gradle configuration, which is by default a project directory name. If you want to change it you can do so by adding the following in the settings.gradle file:
rootProject.name = 'newProjectName'
See also the Naming recommendations from Gradle.

Gradle files not recognised in new directory structure?

Previously we made a Gradle project in Intellij and all the gradle files were there under the project. However, we have now moved the files in this project to a sub folder, but the Gradle files aren't being recognised. The picture below is the new folder set up where our code from the original project is now in the server folder (where the Gradle files are). When I mark the src folder (under server) as the Sources Root, that is when the dependencies from Gradle aren't recognised.
I figured out that the correct way to go is actually to separate out the client/server folder into two separate modules.

Is there anyway to specify project-specific coding style that will get loaded in IntelliJ from a pom.xml?

If I have a Maven project, and someone is going to load the project by opening the pom.xml file in IntelliJ, is there anything I can put in the file or elsewhere in the project that will load project-specific coding styles into the IDE?
Not by importing from a pom only. What you can do is add some IntelliJ files to the source code management tool. Idea saves its project specific code styles into /.idea/codeStyleSettings.xml - it may just picks it up after you imported the project via maven/pom.xml. I think it does not hurt to add a few other files too. Here is my .gitignore for intellij 13.1.5:
target/
# intellij settings files:
.idea/artifacts/
.idea/dictionaries/
.idea/copyright/
.idea/inspectionProfiles
.idea/libraries/
.idea/scopes/
.idea/compiler.xml
.idea/uiDesigner.xml
.idea/vcs.xml
.idea/rebel_project.xml
.idea/dataSources.ids
.idea/workspace.xml
Everything else is under version control. (some developers dont like that - I know - just wanted to mention it)

How to configure Maven project to not expect resources directory in Eclipse

I do not have any resources for my Maven project so I want to stop Maven expecting these directories and so remove these Java Build Path Problems in Eclipse,
Project 'XXX' is missing required source folder: 't-services/src/test/resources'
Project 'XXX' is missing required source folder: 'tlib/src/main/resources'
How do I configure pom.xml to achieve this?
A quite old thread, but I just faced the similar errors in Eclipse, after having deleted the src/main/java + resources and src/test/java + resources from Eclipse directly, as my project is only containing a pom file (packaging=pom).
To properly remove the errors, I just right-clicked on the project > Properties > Java Build Path > 'Source' tab, and there I removed the obsoletes entries. In the end, it modified the .classpath file of the project.
Janek, I saw similar with m2e <= 1.0 but it seems to be fixed with m2e 1.1.
I was able to clear up a similar problem. I removed the projects from Eclipse; deleted all of the .project, .classpath, and .settings files and directories from the file system; imported the project into Eclipse again. The problem went away.
you have to simply remove those folders from your project after that there shouldn't be any problem...But the message gives me the impression that those folders have been configured wrong...

Resources