Adding package name to copyright profile in IntelliJ IDEA - intellij-idea

I'm using Intellij idea. I need to add copyright for package name across the project
tried with ${PACKAGE_NAME} and $pacakage.name but no luck. Also, tried with
$file.qualifiedClassName
but it gets the package along with class name. Let me know the possible variable for getting the package name in copyright.

Copyright profiles are using Apache Velocity engine under the hood. You can try something like:
#set( $dot = "." )
#set( $final=$dot + $file.className)
$file.qualifiedClassName.replace($final, "")

Related

How to disable default gradle buildType suffix (-release, -debug)

I migrated a 3rd-party tool's gradle.build configs, so it uses android gradle plugin 3.5.3 and gradle 5.4.1.
The build goes all smoothly, but when I'm trying to make an .aab archive, things got broken because the toolchain expects the output .aab file to be named MyApplicationId.aab, but the new gradle defaults to output MyApplicationId-release.aab, with the buildType suffix which wasn't there.
I tried to search for a solution, but documentations about product flavors are mostly about adding suffix. How do I prevent the default "-release" suffix to be added? There wasn't any product flavor blocks in the toolchain's gradle config files.
I realzed that I have to create custom tasks after reading other questions and answers:
How to change the generated filename for App Bundles with Gradle?
Renaming applicationVariants.outputs' outputFileName does not work because those are for .apks.
I'm using Gradle 5.4.1 so my Copy task syntax reference is here.
I don't quite understand where the "app.aab" name string came from, so I defined my own aabFile name string to match my toolchain's output.
I don't care about the source file so it's not deleted by another delete task.
Also my toolchain seems to be removing unknown variables surrounded by "${}" so I had to work around ${buildDir} and ${flavor} by omitting the brackets and using concatenation for proper delimiting.
tasks.whenTaskAdded { task ->
if (task.name.startsWith("bundle")) { // e.g: buildRelease
def renameTaskName = "rename${task.name.capitalize()}Aab" // renameBundleReleaseAab
def flavorSuffix = task.name.substring("bundle".length()).uncapitalize() // "release"
tasks.create(renameTaskName, Copy) {
def path = "$buildDir/outputs/bundle/" + "$flavorSuffix/"
def aabFile = "${android.defaultConfig.applicationId}-" + "$flavorSuffix" + ".aab"
from(path) {
include aabFile
rename aabFile, "${android.defaultConfig.applicationId}.aab"
}
into path
}
task.finalizedBy(renameTaskName)
}
}
As the original answer said: This will add more tasks than necessary, but those tasks will be skipped since they don't match any folder.
e.g.
Task :app:renameBundleReleaseResourcesAab NO-SOURCE

Intellij method parameter openjdk

I am using Linux Mint with IntelliJ and OpenJDK8. On Windows I can remember that IntelliJ showed the parameter names like in the API doc.
Now I just get some short names like s, l or i, etc.
Example:
Thread.sleep: the hints should be
sleep(long millis); and
sleep(long millis, int nanos);
But they are currently
sleep(long l); and
sleep(long l, int i);
like you can see in the picture.
In the project structure, the documentation path is already set to https://docs.oracle.com/javase/8/docs/api/.
Is this a problem with OpenJDK?
I solved that issue:
First I installed the openjdk-8-source. Seems like the archive was only a link to a non existing dir. Now it points to ../openjdk-8/src.zip.
After that in the Project Structure in IntelliJ - Platform Settings - SDKs the Sourcepath tab was empty. So I added path to the src.zip dir.

Rally Web Services REST API - Ruby Toolkit

I'm trying to update the Project an artifact belongs to. I am not getting any errors but the artifact's Project does not change. I can successfully change the artifact's notes, name, and other attributes, but not Project. I'm not sure if I'm specifying the Project name correctly in the call:
updated_artifact = #rally.update(:hierarchical_requirement, "FormattedID|" + artifact.FormattedID, {"Project.Name" => "Project A"})
Got help from CA Support and resolved this. If you want to update an associated/referenced field, you'll need to send the URL reference to the Project and supply whatever the OID of the project is, like so:
updated_artifact = #rally.update(:hierarchical_requirement, "FormattedID|" + artifact.FormattedID, {"Project" => "/Project/OID"})

Phpstorm: add copyright information / licence header to files in project

My existing files miss copyright info. I want to add a licence header to severals files in a project with Phpstorm / other JetBrains IDE.
This page doesn't help: https://www.jetbrains.com/idea/help/topicId609815.html
Anyone know the process please?
In 2016 JetBrains added a Copyright tool exactly for this purpose.
See https://blog.jetbrains.com/phpstorm/2016/01/managing-copyright-notices-in-phpstorm/ for more information.
I have the same requirement, but the closest thing I could get is to use the Live Templates feature. Basically I added a new Template under the PHP Group with the abbreviation copyright and the following text
/**************************************************************************
* Copyright (C) $user$, Inc - All Rights Reserved
*
* <omitted copyright blah>
*
* #file $file$
* #author $user$
* #site <my website>
* #date $date$
*/
Unfortunately it seems impossible to use Template Variables such as ${NAME} in the context of a Live Template, so you are forced to stick with the provided expressions. In this case I used fileName(), user() and date() which were enough for my case.
Finally you can type copyright and press Tab to generate the header.

Gradle / Groovy properties

I would like to control 'global' config in Gradle build scripts using external property files on each build machine (dev, ci, uat,...) and specify the filename with a command line argument.
e.g. gradle -DbuildProperties=/example/config/build.properties
I specifically don't want to use gradle.properties as we have existing projects that already use this approach and (for example) we want to be able to amend database urls and jdbc drivers without having to change every project.
So far have tried:-
Properties props = new Properties()
props.load(new FileInputStream("$filename"))
project.setProperty('props', props)
which works but has a deprecated warning, but I can't figure out how to avoid this.
Have also tried using groovy style config files with ConfigSlurper:-
environments {
dev {
db.security {
driver=net.sourceforge.jtds.jdbc.Driver
url=jdbc:someserver://somehost:1234/some_db
username=userId
password=secret
}
}
}
but the colons and forward slashes are causing exceptions and we don't want to have to mess up config with escape characters.
There must be a non-deprecated way to do this - can anyone suggest the 'right' way to do it?
Thanks
You can get rid of the deprecated warning quite easily. The message you got probably looks something like this:
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "props" on "root project 'private'", value: "true".
It can be fixed by replacing:
project.setProperty('props', props)
with
project.ext.props = props
Just to supplement the response given by #Steinar:
it's still possible to use next syntax:
project.ext.set('prop_name', prop_value)
in case you have several properties from file:
props.each({ project.ext.set(it.key, it.value)} )