lundi 12 janvier 2015

How to 'tag' packages and place them in a filtered maven property


Vote count:

0




We are trying to "tag" entire packages from app1 for scanning by app2 that will depend on an artifact from app one. And, so sake of simplicity we only want the code for processing and scanning this dependency done once. When the version from app1 bumps, app2 can bump and if there are new files or even new or renamed packages to scan then app2 simply discovers this and no one has to do anywork.


so app1 wants to "expose"



com.company.model.abc
com.company.model.def


but in a newer version a new package is added and the previous 2 are moved:



com.company.org1.model.abc
com.company.org2.mode.def
com.company.model.ghi


Ideally, app2 should only have to do this integration once.


I had imagined an alias that gets set in a filtered maven property file. Something like



model.packages = com.company.org1.model.abc, com.company.org2.mode.def, com.company.model.ghi


Such that, in app2 code we can simply do:



import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
public class EntityService {

@Value("${model.packages}")
private String[] packages;

@Cacheable
public Set<Class<?>> getEntityClasses() {
Reflections reflections = new Reflections(packages, new SubTypesScanner(false));


Set<Class<?>> subTypesOf = reflections.getSubTypesOf(Object.class);
return subTypesOf;
}
}


I was thinking that basically having a



package-info.java



in each to-be-exposed package might work. Thoughts? I am tagging this with Spring as those who follow spring are quite likely to have a Spring available way of doing this



asked 44 secs ago







How to 'tag' packages and place them in a filtered maven property

Aucun commentaire:

Enregistrer un commentaire