I've been having problems weaving this project correctly with AspectJ (ajc). Here's the situation :
I'm using a benchmarking library called DaCapo Benchmarks, and in it I'm trying to intercept all calls to Iterator.HasNext() and Next() [academic research]. This seems to be working in a vacuum, however DaCapo works in a way such that it's own jar contains other jars which it extracts according to which benchmark I want to run along with it's dependencies and runs it.
I want to intercept all HasNext()s and Next()s with the same aspect so my total is tracked across all the jar files instead of in each individual one.
I hope I'm coming across as clear enough. I'm fully available to answer any questions you might have in order to be able to help me through this weird problem.
P.S. I have the weird feeling it's not actually doable, but a test in eclipse with AJDT (I'm using raw aspectj with ajc for the DaCapo Benchmarks weaving) hints at the possibility.
I know it is too late but may help someone else . .
Whatever i understood from your question is you want to wave same aspect in multiple jars .
So there are 2 ways
if you are using eclipse :
Then create aspect project and go to its properties > click on aspect build option at left panel >select inpath tab at right panel > now click on add external jars > add the jars you want to wave the aspect into >click on OK
again go to its properties > click on aspect build option at left panel >select Output jar tab at right panel >and give the name for new jar you want to create . .>click ok .
create and write your aspect and build or clean your project . It will generate The jar in root directory of project by the name you have given in the "output jar" and this jar will have all the jars you have given in inpath jars with aspect waved . . Thats it . .
If you are using command propmt then :
Write your aspect for intercepting mehtods you want to .> now fire following command on command prompt :
ajc -inpath myJar1.jar -inpath myJar2.jar myAspect.java -outjar MyOutputJar.jar
thats it it will generate final jar with all jar you mentioined in inpath . . You can use as many -inpath as many jars you want to wave code into .
For any dependency error, give required dependency jars in classpath.
If you are using load-time weaving, it is unlikely that this is possible. There is a circularity problem. You need to weave the JDK, but the weaver needs the JDK to load itself and so many parts of the JDK cannot be woven using LTW.
So, you will need to go with compile time weaving. Something like this will work:
ajc -inpath rt.jar -outjar woven_rt.jar *.aj
I'm not sure if this is the problem you are having, but it might fix things.
Related
In a simple IntelliJ module, I just want to generate a .jar file with my .class files, via IntelliJ IDE commands.
Please be careful before marking this as a "duplicate":
Although I've seen Google and Stack hits with promising titles, I'm not finding a really good answer, or the title is misleading, or its an unanswered question. I cover one possible answer that I've seen before (below), and why I don't think it's a match.
I've used Eclipse in the past, but I'm rather new to IntelliJ.
I've worked with the "Project Structure / Artifacts" stuff. I can generate the giant jar, similar to using "shade", but it's huge because it includes all the nested dependencies. We want the small jar with just this module's class files because the system we're deploying to already has all the other jars in place.
I've seen some references to changing a target directory in the Artifacts dialog box, but it then talks about references being made in the Manifest file, which I don't want. The destination environment already has its java paths setup, so I'm worried that having jar references in this jar will mess that up. If this really is the answer then I'm confused about how it works.
Constraint 1: Can't use command line tools, since I'm actually walking somebody else through these steps, who likely doesn't have command line tools installed in the path, or wouldn't know how to use them, etc. They're not a coder. (Yes, I know this sounds like an odd scenario; I inherited this situation.)
Constraint 2: We want to keep this as a simple IntelliJ project, vs. converting to Maven or Ant or Gradle, etc.
Coworker had the fix.
Short Answer:
Remove all of the other jars/libraries from Output Layout tab of the Artifacts config dialog.
Longer Answer:
You still do File / Project Structure...
Then in the Project Settings, click Artifacts.
And then you still click the plus button (second column) ti create a new artifact setting.
The trick is the "Output Layout" tab in the third column of the window. Highlight all entries EXCEPT the compiled output of your project and delete all those other entries (click the minus button under that tab, directly above your_project.jar)
On my laptop this causes it to pause for a few seconds; I thought it didn't do anything, then finally it reflected that everything was gone except "'my_module' compile output"
Also check the "Build on make" (for when you later do Build / Rebuild Project)
If you need both a full jar and a slim jar, you can have more than one Artifact configuration with different names, and they will default to different output directories.
I have an EAR file that contains two different jars that share some classes with an identical package+class name. This results in importance of classloading inside the EAR file itself.
How can I tell Weblogic to load one jar from APP-INF/lib before loading a different one in the same APP-INF/lib? I need to define a specific order to that if there is a conflict, it will take from JAR a and not JAR b.
I'm using Webogic 11g (10.3).
Thanks.
The top-level element in weblogic-application.xml has an optional classloader-structure element that you probably want to look into. For instance you can do something like:
<classloader-structure>
<module-ref>
<module-uri>ejb1.jar</module-uri>
</module-ref>
<module-ref>
<module-uri>web3.war</module-uri>
</module-ref>
<classloader-structure>
<module-ref>
<module-uri>web1.war</module-uri>
</module-ref>
</classloader-structure>
</classloader-structure>
Read more about declaring custom class loading at these Oracle docs. You may also find the Classloader Analysis Tool (CAT) at the same link of interest.
If you're getting ClassNotFound exceptions, try checking out the MANIFEST.MF for each of your modules to see if the "Class-Path" attribute is correctly populated with the locations of your jars in your APP-INF/lib - I've just spent a week or more tearing my hair out trying to find a solution to a similar problem, and this is what fixed it.
Moving to intellij i'm trying to understand properly the logic behind the its project structure. I come from eclipse. After reading for a while i understood the relation between workspace and project, then between project and modules. However something that is puzzling me is the logic of the default project configuration in Intellij. Indeed, when you create a project there is an initial module which to a certain extend is equivalent to the Project itself. To be more precise, the initial module folder is the Project folder. This is kind of confusing to me. Then when you add more module they are sub-module of that module.
My first question is what is the rationale of making this first module equivalent to the project folder ?
Following this, i would further ask, what the point of having modules as sub-module of others.
In eclipse i use to have simply different project (i.e. module) independent from each other and adding the dependency as necessary. So how does the Idea solution makes it better, if not what is the rational here ?
I saw that one can start an empty project and then add modules to it. However in that case, the modules added are added as subfolder of the Project and therefore there is no initial module equivalent to the Project folder ? So why this difference and what is the rationale behind it ?
What would be the better approach, the first or second ?
Would it be ok to have this first initial module with no src or test folder but just with the proper facet so as to spread it to the sub-module?
I would appreciate if someone could explain a bit the rational of all of it ?
I will move to SBT soon (i.e. maven structure which I suppose inspired all modern IDE project Structure) if one want to explain within that context fine, nevertheless i want to understand the rationale in intelliJ first.
Many thanks,
-M-
PS: What i'm looking for is some advise for some multi-module project structure in Intellij as i'm moving my eclipse workspaces to it.
I think that it's not uncommon for projects to be relatively small, so they don't need fancy modules with dependency management etc. In that case, I find the default project created by IntelliJ to fit perfectly my needs: no need to add submodules, everything is directly in the parent project, it reduces the structure to its bare minimum.
On the other hand, big projects with submodules will likely resemble the structure of a Maven multimodule project (perhaps SBT too, but I don't know this tool at all). You have a parent root which acts as a container for submodules. The parent project may also store configuration (a default SDK, a language level etc. that will be inherited by the submodules). The actual code will be contained in the submodules.
Regarding your questions, it all depends on the kind of project you are developing. For a small codebase, you could keep a simple project with no submodule. For bigger codebases, you can either create modules manually, or import an existing Maven/SBT/whatever project, which will automatically create modules reflecting the imported structure.
We're trying to migrate from current Ant build to Maven. In the current project, we've different properites files for each of the env say
qa.properties, prod.properties & dev.properties.
The property values present in these files, are used to replace wherever these properties are being referred through config files (present in src\main\resources\config ). The current Ant build process replaces all these properties which are being referred in config files with their corresponding value for the current build env.
I'm somewhat aware of the Profiles concept in maven. However, I'm not able to figure how to achieve this using maven.
Any help would be appreicated.
Thanks,
Prabhjot
There are several ways to implement this but they are all variations around the same features: combine profiles with filtering. A Maven2 multi-environment filter setup shows one way to implement such a setup (a little variation would be to move the filter declaration inside each profile).
See also
9.3. Resource Filtering
Today I'm on a mission to remove little red X's from my django project in pydev. Mostly, this involves fixing import problems with pydev.
I'm using South for database migrations. South (if you don't know) generates python modules, and pydev doesn't like them. I don't want to edit the south code since it's generated.
Is there a way to instruct pydev to exclude certain packages from analysis? Something like ##UndefinedVariable, except for the entire module? Ideally I'd like to ignore packages named "migrations".
In South, I have added a "##PydevCodeAnalysisIgnore" to the templates in south/management/datamigration.py and south/management/schemamigration.py. It doesn't let me ignore entire packages, but serves my purposes well enough.
I have lots of generated code. To avoid PyDev complaints, I postprocess those modules as follows (bash script):
for file in `find gen -name '*.py'`; do
mv $file $file.bak
echo '##PydevCodeAnalysisIgnore' > $file
cat $file.bak >> $file
rm $file.bak
done
Yes, you can put ##PydevCodeAnalysisIgnore at the beginning of each file that you want to ignore, but that means that you're coding to your IDE, which isn't best practice. I prefer instead to change my project settings so that
some troublesome patterns are ignored by Eclipse (by adding to Preferences -> PyDev -> Editor -> Code Analysis -> Undefined)
some troublesome files are ignored by Eclipse (by adding an exclude filter to Project Properties -> Resource -> Resource Filters -> Add Filter...)
In your particular case, I had the exact same problem and decided to exclude South migrations from the Eclipse project. On the few occasions that I needed to edit these auto-generated files, I didn't use Eclipse.
UPDATE:
One other option is to right click on your project and select PyDev -> Remove error markers -- but don't do this if there are any errors that you don't want hidden!
Although not directly related to this question in terms of disabling individual migration files from analysis, PyDev's built in code analysis was causing me real headaches here on Windows, when the same project and settings has no problem on Mac OS. This lead me to this question, on how disable analysis for certain resources. There is a large folder part of the project and excluding this resource using Eclipse -> (the folder) -> Properties -> Resources -> Filter (exclude) didn't even help.
Having the exclusion along with using PyLint fixed the insanely slow build times. YMMV.