• Post Reply Bookmark Topic Watch Topic
  • New Topic

Way to make alias for package names when importing?  RSS feed

 
I Lopes de Sarria
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Is there a way to create an alias or placeholder name for package names in classes? This is my use case: I am using an API that has the year and month of the latest version in the package name eg firstpartofpackagename.201203 for example. Now every time a new API is released i can't simply change the jar file that my project references and re-deploy the code, but i have to do a find and replace on all my classes to use the new version of all these packages in all my imports, and recompile the code.

Is there a way to create a configurable placeholder/alias for the updated packages that i can use in the classes?


Many thanks
 
Stephan van Hulst
Saloon Keeper
Posts: 7987
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a really bad way of using packages, and I urge you to drop it. If you want to have different versions, you should probably have different projects with different classpaths. A package is a logical aggregation of classes, and dates should have no bearing on them.
 
I Lopes de Sarria
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree, but unfortunately this is not my api but one of Google's, that I am merely using. There are already 6 versions since the beginning of last year , and i was really hoping that there would be a way around this

Thanks for your input
 
Stephan van Hulst
Saloon Keeper
Posts: 7987
143
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh sorry, I misread. I thought you yourself were naming your packages that way.

I don't think there's a painless way around this, other than simply not updating your libraries. Maybe you can send Google a letter to complain about this astoundingly silly idea.
 
Stephan van Hulst
Saloon Keeper
Posts: 7987
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, if you're only using a very small part of their API, you can write some wrapper classes which your own program uses. You then only have to update your wrappers periodically.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!