Determine projectName for VS Code launch from maven projects - maven

I am working in a complex project structure of bundles and plugins for karaf.
When attaching to the process, I cannot use WATCH as the project cannot be found:
Cannot evaluate because of java.lang.IllegalStateException: Project XY cannot be found..
Is it possible to determine the correct project name from the file the breakpoint is in and the maven file its contained in?
For some reason the content inside XY does not work.
This is the launch config:
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Debug Karaf",
"projectName" : "XY",
"request": "attach",
"hostName" : "localhost",
"port": 5005
}
]
Edit: Breakpoints and step by step debugging do work. Its strange that these two things are different.

The project name XYZ that worked for me was in the pom building the jar file under artifactId: <artifactId>XYZ</artifactId>.

Right-click on a Java file (one without a main() function) and choose "Run Java" and you'll get a prompt with a few options. This prompt will show the project name.
As you can see in this screenshot of this Ant project, sometimes the project name is unpredictable.

Related

How could I change the name of my Yarn Workspace package?

I starting with a yarn workspace that has packages that are already named. I'd like to change the name of one of the packages but have not been able to find the necessary procedure for doing this.
Here's the current structure of the file:
{
"name": "gatsby-starter-theme-workspace",
"private": true,
"version": "0.0.1",
"main": "index.js",
"license": "0BSD",
"scripts": {
"build": "yarn workspace example build"
},
"workspaces": [
"gatsby-theme-minimal",
"example"
]
}
The workspace name that I'd like to change is gatsby-theme-minimal, I'd also like to know how I'd change the other one example when that becomes necessary, so advice on that would also be appreciated. I appreciate that this is probably a simple process but I am as yet unaware of how it is done.
There are two concepts that is used in your question.
The directory name of the workspace. To change it just rename the directory and update workspaces field to refer to the new directory name
The package name of the workspace - it is provided in package.json inside name field for the corresponding workspace. For gatsby-theme-minimal it is provided inside gatsby-theme-minimal/package.json -> name. Just edit package.json and change the name.
After making changes via 1) or 2) or both of them you need to run yarn in order for Yarn to update any installation files that refer to them. If you change workspace package name as per 2) you should also edit and update any code that requires/imports workspace by the old package name.

Reuse package.json version within file

I have a project which uses dependency having having version same as that of the project. So I would like to change the version only in one place and write something like below this in my package.json
{
"name": "my-child-app",
"version": "1.2.3",
"description": "My Application",
"dependencies": {
"my-parent-app": %npm_package_version%
}
}
Basically the child app is always supposed to have version in sync with the parent app. So any approach where I will have to change only one line (instead of two in usual scenario) when I have to upgrade to a newer parent-app would suffice.
Note: I am using frontend-maven-plugin to build the project as child-app is a module of Java Project. parent-app is also built in a same way but they are not in the same code repository so file referencing cannot be used.

Download files from Artifactory to Teamcity without retaining their full path

I am using
TeamCity Enterprise 2017.1.2 (build 46812)
Artifactory Professional 5.3.1 rev 50046
Teamcity has the Artifactory plug-in installed (ver 2.3.0)
The task is simple - download files from Artifactory to Teamcity build:
From Artifactory MyRepo/RootFolder/ProjectFolder/1.2.3/<files>
To TC %checkoutdir%/artifacts/<files>
The <files> part of the path contains both folders and files and I want to retain their structure.
The download spec json is:
{
"files": [
{
"pattern": "MyRepo/RootFolder/ProjectFolder/1.2.3/",
"target": "artifacts/"
}
]
}
However, the files get downloaded into a different location than I would expect:
Actual: artifacts/RootFolder/ProjectFolder/1.2.3/<files>
Expected: artifacts/<files>
The whole path from Artifactory gets appended after the target directory. How do I tell the plugin to only use the relative path of files after the specified root? I have tried fiddling about with wildcards, slashes etc, but nothing helped.
I had to create an extra build step where I manually move files to the structure I expect, but I would prefer not to have to do that.
WORKING ANSWER:
{
"files": [
{
"pattern": "MyRepo/RootFolder/ProjectFolder/1.2.3/(*)",
"target": "artifacts/{1}",
"flat": "true"
}
]
}
You can customize your target structure by using Placeholders in your File Specs as described here.
Placeholders allow you to capture a specific section of your File Spec "pattern" property value, and use it inside the "target" property value.
In your case, the download File Spec should look like this:
{
"files": [
{
"pattern": "MyRepo/RootFolder/ProjectFolder/1.2.3/(*)",
"target": "artifacts/{1}"
}
]
}

Go importing vendor dependencies issue when building a Go 1.7 project using govendor, dh-make-golang

I've been looking into building a go project into a debian package.
I've looked into dh-make-golang and I have a nice and shiny debian folder set up in my repository. When I try to use gbp buildpackage --git-pbuilder though it errors out due to all of my dependencies not being found. It seems that dh-make-golang ignores the vendor folder when it copies everything from my project's git repository, and I use govendor so all of my dependencies are in there.
How can I resolve this dependency issue and build the project as a .deb package properly? For reference, the error I am getting is:
src/github.com/project/project/project.go:15:2: cannot find package "google.golang.org/grpc/grpclog" in any of:
/usr/lib/go-1.7/src/google.golang.org/grpc/grpclog (from $GOROOT)
/tmp/project/obj-x86_64-linux-gnu/src/google.golang.org/grpc/grpclog (from $GOPATH)
Issue was a bug in dh-make-golang regarding importing vendor dependencies. It was just fixed today.
https://github.com/Debian/dh-make-golang/issues/46
Take a look at goxc - it can do this for you!
You simply need to add a .goxc.json to the root of your directory, that looks like this
{
"AppName": "my_app",
"ArtifactsDest": "downloads",
"Tasks": [
"interpolate-source"
"deb",
],
"BuildConstraints": "linux,amd64 windows,amd64 darwin,amd64 linux,arm",
"ResourcesInclude": "INSTALL*,README*,LICENSE*,config/*,static/*,templates/*",
"PackageVersion": "0.9.3",
"TaskSettings": {
"deb": {
"metadata": {
"description": "my app",
"maintainer": "me",
"maintainer-email": "me#example.com"
},
"metadata-deb": {
"Homepage": "https://example.com"
},
"other-mapped-files": {
"/": "debian/",
"/usr/share/something/static": "static/",
"/usr/share/something/templates": "templates/"
}
}
},
"ConfigVersion": "0.9"
}
Then run goxc and it'll do all the work for you.

Global.json and running web application

I am trying to create a new web application using OS X and VS Code from scratch without using any scaffolding tool. My starting point is Scott Allen's tutorial on pluralsight:
https://app.pluralsight.com/library/courses/aspdotnet-core-1-0-fundamentals/table-of-contents
My project structure is:
The global.json file contains
{
"projects": [ "src" ],
"sdk": {
"version": "1.0.0-rc1-update2"
}
}
And the project.json currently contains
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": false
},
"dependencies": {
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final"
},
"frameworks": {
"dnx451": {},
"dnxcore50": {}
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000"
},
"exclude": [
"wwwroot",
"node_modules"
]
}
I have run dnu restore to get the packages and now I would like to run the web. I need to go to the web app folder and run dnx web in order to do so and the app starts
Is it possible to run the application directly from the root folder, not from the web app folder? Is the global.json file needed in such setup? And how do I change the hosting environment? I have gone through the documentation, but the hosting environment is only clear when using VS 2015.
You cannot simply run from the root because there could be multiple projects that are "executable". But you can pass the project to dnx using the --project/-p argument.
The environment is set using the ASPNET_ENVIRONMENT environment variable.
The global.json file is useful for two things:
The sdk section is only by VS.
The projects section is used all the time and it's useful if you have the projects in multiple folders (for example src and test). If everything is in a single folder, you don't need it.
So, the bare minimum in order to run an web application is:
A folder for your project
A project.json file
A startup file

Resources