Creating a package under source folder when developing an eclipse plugin - eclipse-plugin

I am developing an Eclipse wizard that will be used for creating a project. I can create the folder hieararchy but I cannot create a package under "src" folder. I found this answer How to create packages (folders) in an Eclipse project via plugin here. However, it does not solve my problem. When I create a folder under "src" folder, eclipse does not recognize it as a package. How can I do this?

Try this using JDT API as below.
private void createPackage(IProject project) throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
IFolder folder = project.getFolder("src");
// folder.create(true, true, null);
IPackageFragmentRoot srcFolder = javaProject
.getPackageFragmentRoot(folder);
IPackageFragment fragment = srcFolder.createPackageFragment(project.getName(), true, null);
}
for more help please access this link

Related

How to setup my KorGE project to use Fleks ECS library?

I want to use Fleks ECS as shown in this example:
https://github.com/korlibs/korge-next/tree/main/samples/fleks-ecs
How to setup my KorGE project to be able to import the Fleks library?
I found that there is a built in function to import the Fleks into KorGE project.
Just configure the build.gradle.kts file as in the example below:
...
korge {
id = "com.example.mygame"
name = "My Game"
supportFleks()
targetJvm()
targetJs()
targetDesktop()
targetIos()
targetAndroidIndirect() // targetAndroidDirect()
}

How to customize WAR plugin in subproject in Gradle build script (Kotlin)

I create a Gradle project with several sub-modules, and one module needs war plugin, I just want to customize the web app directory, but the code does not work:
apply {
plugin("war")
plugin("org.gretty")
}
// cannot work
tasks.getByName("war") {
from("src/main/webfiles")
}
// cannot work either
tasks.war {
webAppDirName = "src/main/webfiles"
}
//... other code
This is how I code in the sub-project subproject.gradle.kts file, How to solve this? Thanks for any help!
Solved with the code:
configure<WarPluginConvention>{
webAppDirName = "src/main/webfiles"
}

Swagger-UI and Ktor how to import swagger.json or .yaml file and start Swagger-UI?

I have a problem, I have already generated OpenApi Swagger files (swagger.json and swagger.yaml) Is it possible somehow in Ktor (kotlin) import this files and start swagger-ui server on specific route ?
I have visited ktor-swagger project but could get how just to add json file to display swagger-ui.
Any suggestions ?
Make you json file accessible from static routing
Create "files" directory in resources dir
Use next code to routing static files from "files" dir
routing {
static("/static") {
resources("files")
}
//...
}
Lets name json file "test.json", then put you it in "files" folder
so now you run the app and see this file by http://localhost:8080/static/test.json
Then we need to install and configure OpenApiGen
Add OpenApiGen dependencies you can find how to do this here https://github.com/papsign/Ktor-OpenAPI-Generator
Then use the following code
install(OpenAPIGen) {
serveSwaggerUi = true
swaggerUiPath = "/swagger-ui"
}
now you can use http://localhost:8080/swagger-ui/index.html?url=/static/test.json URL to see your file through the swagger UI
Also, you can provide your own route to using redirection
get("/api") {
call.respondRedirect("/swagger-ui/index.html?url=/static/test.json", true)
}
this will allow you to use just http://localhost:8080/api

Asp .Net Core 3.1 Publish wwwroot folder Email Templates

I have a simple application using .net core 3.1 with a very simple ContactUs form. Everything is working fine except Publishing.
I am using Core CLI to publish my project using the following command
dotnet build SampleApp.csproj /p:DeployOnBuild=true /p:PublishProfile=Local
Here is my wwwroot folder:
When I publish my app except for templates folder in wwwroot everything is published properly.
Here is my .csproj file:
My question is how to publish the template folder using CLI?
Unlike ASP.NET MVC 5, during publish in ASP.NET Core .cshtml view files are compiled to .dll file, that's why your templates folder containing .cshtml files in wwwroot folder are being omitted during publish.
Better move your EmailTemplates folder inside Views folder in the project. Then everything will work as expected.
Two ways you can do this :
First Way -->
change .cshtml to .html for html templates and it will surely work without any other change.
Second Way -->
Follow this :
1). Make emailtemplates folder in the parent directory.
2).Copy your all email-templates in emailtemplates folder which was created in parent directory.(use .html instead .cshtml for templates)
3). Then use it in any controller like below.
Example :
public class HomeController : ControllerBase
{
private readonly IHostingEnvironment _environment;
public HomeController(IHostingEnvironment iHostingEnvironment)
{
_environment = iHostingEnvironment;
}
public string LoadTemplate()
{
string FilePath = _environment.ContentRootPath;
var PathWithFolderName = Path.Combine(FilePath, "emailtemplates");
var file = PathWithFolderName + "\\" + "contact-us.html";
using (StreamReader r = new StreamReader(file))
{
string html = r.ReadToEnd();
return html;
}
}
}

asp.net mvc-4 and grunt-uglify

How to manage .min files generated by grunt-uglify and "debug" version?
If I set
BundleTable.EnableOptimizations = true;
or at web.config
<compilation debug="false" />
apparently the bundle concat all files by itself and don't use the min files generated by grunt.
All debug version has their own minify version at the same folder ex:
Folder A
testA.js
testA.min.js
...
Folder B
testB.js
testB.min.js
...
PS: I'm not referencing minified files in bundleConfig.cs.
What is the best solution to handle it? I need to use ONLY minified files generated by GRUNT at the release moment, and still using debug version when in development.
BundleTable.EnableOptimizations = true;
This code works only if you're using BundleConfig.cs
I think that the best way for you is to create a custom UrlHelper that can build JS scripts url according to if you're in debug mode or not (this is pseudo-code) :
public static class UrlHelper
{
public static string JsScript(this UrlHelper urlHelper, string baseFileName) {
return HttpContext.Current.IsDebuggingEnabled
? urlHelper.Content(baseFileName + '.js')
: urlHelper.Content(baseFileName + '.min.js');
}
}
And for example, if you want to use it in your Razor view :
<script src="#Url.JsScript("~/js/folderA/testA")"></script>