How to do gradle build on nested projects - eclipse

I am trying to build the java projects with gradle and my project structure something like below:
Root
|
|----Child
| |
| Child1 (build.gradle)
|
|
|----Child12
| |
| Child111
| |
| Child222(build.gradle)
|
settings.gradle
As you can see, the project structure, here I am doing the gradle eclipse build for all the projects (Child1, Child222) in a single attempt by modifying settings.gradle and including the child projects something like below:
include 'Child/Child1'
include 'Child12/Child111/Child222'
Build is fine with that.
Whereas, while importing the projects(Child1, Child222) into eclipse, I am getting the following error:
Creation Problems
Path for project must have only one segment.
Because, in the Child1 .project file
<projectDescription>
<name>Root/Child1</name>
<projectDescription>
project name appearing as Root/Child1, instead of Child1.
Is there anyway, with that I can import the projects into the eclipse?

I got it, I changed settings.gradle file like below:
include 'Child:Child1'
include 'Child12:Child111:Child222'
It's working fine for me.

Related

An umbrella Scala project. How to create multimodules project with multiple versions of scala, and libs?

Is there a way to create an umrella project and to specify what version of scala, or lib/s to use for each module independently?
I'd like to create a multi-module project.
Each module covers one scala version.
Each module may include submodules each of which includes some set of libs.
Non of modules interact with each other.
Each of which has it's own build.sbt file, and describes it's own set of libs.
There should be ability to build each of these modules to get a jar file.
It may have a different shape, the idea is to keep all the libs I'm playing around with in one place.
|root
|
|-|A
| |-|B
| | \build.sbt(lib1)
| |
| |-|C
| | \build.sbt(lib2)
| \build.sbt(scala_version="2.13.1")
|
|-|D
| |-|E
| | \build.sbt(lib1)
| |
| |-|F
| | \build.sbt(lib4)
| \build.sbt(scala_version="3.1.1")
|
build.sbt
I've already tried:
1. .aggregate(A,B) in the 'root' build.sbt
2. crossScalaVersions := supportedScalaVersions
3. define build.sbt files for each module independently.
The solution for IntelliJ IDEA users could be found here.
Add all the desired modules using sbt.
Press ctrl + alt + shift + s
Group(right button, then 'Change Module Names...') them.

How to use babel-cli directory paths?

EDIT: Answered, below.
Also: If you are reading this you are probably new to web dev and you should consider using webpack for this instead of babel alone
I have what seems like a very simple problem but I can't solve it.
I have a directory structure
Project
|
+-- scripts
|
|
+-- src / src.js
|
|
+-- compiled / compiled.js
And I have been trying to get the following command to work when my terminal is located in the scripts folder.
C:\Users\me\JavaScriptProjects\survey\scripts>npx babel ./src/src.js --out-file ./compiled/compiled.js presets=env,react --watch
But it simply keeps returning:
C:\Users\me\JavaScriptProjects\survey\scripts>npx babel ./src/src.js --out-file ./compiled/compiled.js presets=env,react --watch
presets=env,react doesn't exist
I have tried permutations of removing the ./, replacing it with only /, going into src dir and replacing src/src.js with src.js and then doing ../compiled/compiled.js and many other permutations, but it just keeps saying it doesn't exist.
Even if I add both files to the same directory it's giving the same error.
Most annoying part is it was working fine yesterday.
Thanks in advance.
Solved.
The following has worked from within the src dir after trying for around an hour. I don't know what I've done differently, would love it if someone can point it out.
Thanks.
C:\Users\me\JavaScriptProjects\survey\scripts\src>npx babel src.js --out-file=../compiled/compiled.js --presets=env,react --watch
It could be that you have a babel.config.json file in the \scripts\src folder and that if you move to the \scripts folder to run npx, then it can't see the config file and so doesn't see react.
Project
|
+-- scripts
|
+-- src / src.js
+-- src / babel.config.json
|
+-- compiled / compiled.js

vscode omnisharp not working for solution but works for project

I have folders structured like this: project/csproj A, project/csproj B
If I open in vs code project dir, omnisharp works for csproj B only. If I open in vs code project/csproj A directory, omnisharp works for this project.
How fix that so I can open project directory and have working omnisharp for both projects?
Broken project is nunit type if that matters. I tried reloading vscode, disabling/enabling omnisharp.
I created project in empty directory with
dotnet new nunit -n=projectB
A solution is specified by a sln file, if you don't have one yet, just create a new one in the solution-level folder
dotnet new sln
And then, you must add the project references to the solution
dotnet sln path/to/solution add path/to/project
And if the omnisharp does not update it, restart it or vs code.
Omnisharp can only support a single project or solution, therefore, to support multiple projects, you must use "solution", which is not just a folder but with a sln file.
Your folder structure is antipattern and not naturally supported, because .NET Core uses SDK-style csproj project, which adds all source files in the project-level folder (which is where the csproj file is), so having multiple csproj files inside one project-level folder is just for one project with multiple targetings. If your project A and B is in the same folder, it means they may contain duplicate source files that may cause errors on conflict of types, unless you specified source exclusion respectively in the csproj files.
The recommanded folder structure is
<Solution and git repository level folder>
|-- src
| |-- <Project level folders>
| | |-- <Folder structures based on namespace>
| | | └-- <Source files>
| | |-- <Asset files with approprate folder structure>
| | └-- <The csproj file>
| |-- Directory.Build.props (Common MSBuild props for all src projects)
| └-- Directory.Build.targets (Common MSBuild targets for all src projects)
|-- test
|-- └-- <Test projects with similar folder structure to src>
|-- build
|-- └-- <Common MSBuild props and targets files to be referenced by src and test>
|-- docs
| └-- <Documents>
|-- <Other repository assets>
└-- <The sln file>

Gradle sub-sub-projects with same name in does not work for eclipse

I have the following structure
root
|- foo
| |- implementation
| | \- build.gradle
| \- interface
| \- build.gradle
|
|- bar
| |- implementation
| | \- build.gradle
| \- interface
| \- build.gradle
|
|- build.gradle
\- settings.gradle
in settings.gradle I have the following:
include ':foo:implementation', ':foo:interface'
include ':bar:implementation', ':bar:interface'
in my build.gradle on the root folder I put all of them as a dependency
dependencies {
compile project(':foo:implementation')
compile project(':foo:interface')
compile project(':bar:implementation')
compile project(':bar:interface')
}
Eclipse needs each project to have distinct names. Gradle by default uses the project name to name these in eclipse. Thus eclipse is unable to distinguish between ':foo:implementation' and ':bar:implementation:' as they both will be named 'implementation' inside Eclipse. In my mind this should have been solvable by setting the eclipse project name to something more specific, e.g.:
allprojects {
eclipse.project {
if (project == rootProject) {
name = rootProject.name
} else {
name = rootProject.name + project.path.replace(":", "-")
}
}
}
With this I get unique project names, but when I look at the .classpath xml only one of the implementation projects and one of the interface projects are present.
Any idea?
So far, I've only been working with "single dir level" multiprojects; For that scenario, there are several ways to fix it:
If you want to fix it for eclipse only and if you're using the "import gradle project" wizard, you might want to set the "Use hierarchical project names" check box. Not sure how it behaves in your case (double dir level)
Next one can hopefully help you out: how to rename the project in gradle instead of using folder name?. Probably with some extra investigation for your double dir level. It will also change the gradle project names BTW
And indeed, The eclipse plugin also provides means to change project names, haven't used it myself though...
Sadly this is a bug with Gradle; see the open GitHub issue.
One (workaround) solution is to use different groups for the subprojects:
// root/foo/build.gradle
subprojects {
group = 'org.example.foo'
}
// root/bar/build.gradle
subprojects {
group = 'org.example.bar'
}

How to create a WAR out of a eclipse project, while minifying all css and js files?

I have a Dynamic Web Project in Eclipse and was wondering if there is a way I can create a WAR and in between minify all my js and css files.
Supposing my project file structure is
iscCSM
|
|
infa9
|
|
csm--ACProxy--include--acproxy--js
| | |
| css *.js
| |
| *.css
|
|
|
view--include--js--custom
| | | |
*.html | *.js *.js
*.jsp css
|
*.css
Update
After googling I got this maven plugin Cactus but I am having problem in configuring pom.xml file to use cactus plugin as given in the same tutorial Can somebody help me which pom.xml I need to modify?
I followed the tutorial and reached the stage where string BUILD SUCCESS appears, but m unable to move forward. Please help.
Web Resource Optimizer for Java (wro4j) is what you are looking for
http://code.google.com/p/wro4j/.
It has support for js, css minifcation, with multiple minificators implementations, and also has support for less,sass, and coffeescript processor.
You can use it as:
maven plugin
standalone application
as library in yours web aplication as ServletFilter - which is nice feater to use during development.