question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

javaType : generate classes in subpackage of the target package

See original GitHub issue

Suppose I generate my classes in target package com.example.

If I specify a javaType property of Foo, it will be generated as com.example.Foo, as expected. However if I specify a javaType property of bar.Foo (with a dot), it will be generated as bar.Foo (i.e. in package bar).

To me it would make more sense to generate it in package com.example.bar.Foo, i.e. a subpackage of the target package. As it is now, if I want to generate classes in subpackages of the target package, I have to repeat the fully qualified package name in every javaType property. And of course if I want to change it I will have to change in all the places it is referenced…

If we want to preserve this behavior for compatibility and still allow generating classes in subpackages, I suggest we introduce the convention that if the javaType begins with a dot, it’s considered relative to the target package.

For example:

  • javaType=bar.Foo -> generates class bar.Foo (same as current behavior)
  • javaType=.bar.Foo -> generates class com.example.bar.Foo

What do you think?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
joelittlejohncommented, Feb 20, 2020

Thanks @ogerardin. I have reopened #195.

0reactions
ogerardincommented, Feb 20, 2020

What prevents you from declaring your javaType to be com.example.bar.Foo?

Nothing, and that would work, but I shouldn’t have to use com.example in the schema because it’s a generation-time parameter. I want to be able to put the generated classes in subpackages of the target package, without knowing what it will be.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 7. Packages - Oracle Help Center
The package java.awt has a subpackage named image , as well as a number of compilation units containing declarations of class and interface...
Read more >
jaxb override package of a specific generated set of classes
I have a large third party xsd file that pulls in a whole bunch of other xsd files through imports. The whole thing...
Read more >
Java Generated Code | Protocol Buffers - Google Developers
The generated class is placed in a Java package based on the java_package option. ... For other simple field types, the corresponding Java...
Read more >
Packages in Java - Know their Importance in Java !! - DataFlair
Creating Packages in Java ... This class is inside the javatutorials package. Compiling Java Package Program. If you are using an IDE, directly...
Read more >
Packages in Java: How to Create/Import Package - Guru99
A Package is a collection of related classes. Learn how to create Package in Java with example program in this tutorial.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found