-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[proposal] check packages names #70
Comments
Just saying, this is actually an issue because it generates invalid java code. Of course it is not an issue if we accept to generate invalid package names, but then it's an inconsistency because the classes do not allow invalid class names. |
@guiguilechat Thanks for the very verbose request :) |
should print the sPart : "The subpackage name " +sPart+" is invalid in package "+sName ?? |
var is not a reserved keyword.
is correct (just checked) |
Let me tell you, sir, about our lord and savior maven. Release pluginI would advise you to use the maven release module
which automatically changes the versions, while still working on the snapshot . However there are a few issues, eg it may break because compilation phases have non-deterministic effect (don't use the mvn clean in that case : instead make two separate calls Other issues is that you may crash and add a tag in local and remote that will later prevent you from actually updating the value to the next version. In that case, delete the tag from local and remote repository with eg You also need to set your csm to a correct value. Here is mine for Jswagermaker :
and the distributionManagement part . skip javadocAlso you can ask mvn to not create the javadoc (a single property in the root pom)
I think it is un necessary when you already export the sources ^^ specify maven version and encoding
java.version is used in the maven-compiler-plugin to enforce the compilation against a specific version.
encoding is specified to be sure everybody gets the code correctly even mac users :) Attach sources on deployuse the plugin, Luke :
as written no-fork prevents from doing it both in the compile and release parts or something like that. Export to an ftp serveryou still need the server configuration in your LOCAL pom.
if it crashes, you need to specify the plugin version in the dependency management.(yeah sometimes maven sucks) |
haha. Okay, will take 'var' off the list again. And of course I know the release plugin. Give me some time to check the other proposal first ;) |
Part of 3.3.0 release |
Sorry I talking about maven because I did not notice a "maven-release" in the commits. Just trying to ease the deployment. Also because I had several colleagues that were very good, just not with maven - and therefore did not eg deploy their sources at the same time they did a release. according to so "_" is not a valid package identifier. This answers my previous question. It is missing from the reserved keywords list Just checked and you added true, false, null, so it's good. Also interesting is Please take all your time :) Sorry I did not intend to rush you. |
should I make a different issue to enhance maven ? |
So the single underscore is resolved. |
actually I think I'm gonna take some things from there … :) |
@phax I'm updating to the latest release, and I cannot generate resource files in the |
@fbaro please provide an example and explain how it is not working. |
Well when I call
|
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
Also,
therefore, the correct package name should be However, if you are creating resources, it's a different issue. But why are you using jcodemodel to generate resources ? Do you have a link to a working example ? |
I'm using JCodeModel to generate a lot of java code, and also some plain text files. I do it because it's possible and supported by the JCodeModel interface (JPackage.addResourceFile). That name is correct as it is, and cannot be changed. See https://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html I'm unable to link to a working example. However the line of code above is sufficient to trigger the exception, no further code is needed. |
That name is correct for the "resource directory", not for a package. If I understand correctly, your issue is that there is no way anymore to create a resource in the directory "META-INF" . @phax I think there should be a separation between resource directories, and packages. With the ability to go from a package to its corresponding resource dir with a asResDir() .
|
There is a solution in ph-jdmc - details after my vacation next week |
Issue
The JDefinedClass constructor checks the validity of the class name, starting here :
https://github.com/phax/jcodemodel/blob/master/src/main/java/com/helger/jcodemodel/JDefinedClass.java#L214
The JPackage constructor, does not, here :
https://github.com/phax/jcodemodel/blob/master/src/main/java/com/helger/jcodemodel/JPackage.java#L116
Proposal
I propose to make the JPackage make a verification test
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
according to this :
Implementation
Here is how I personally do :
Reserved keyword
I keep a list from https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
Then I just check if the name is contained in that set.
All alphanumerical, start with non-numerical
Then I just check if sName matches this pattern. It can accept "_" as a package name, not sure if correct.
Optional check lowercase
Add a boolean option in JCodeModel::ensurePackagesLowerCase(). default value should be false.
Then create a new Pattern to match the package name
To test the name against.
The text was updated successfully, but these errors were encountered: