NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Monezz
Joined: 18 Feb 2009 Posts: 254
|
Posted: Tue Apr 17, 2012 9:47 am Post subject: [platform-dev] Re: How to have two project in one |
|
|
| Quote: | I need to be able to build the original
application and the plugin alone (with additional packages that will be
required), so I could run it as a part of Netbeans IDE (plugin) and as a
standalone application. Is there a way how to do it?
|
When using maven you can use modules in more then one application (or plugin). |
|
| Back to top |
|
 |
MalevolentCat
Joined: 21 Nov 2011 Posts: 20
|
Posted: Tue Apr 17, 2012 9:55 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
Thank you. I'll try Javier's suggestion first. This just might exactly be what I need.  |
|
| Back to top |
|
 |
MalevolentCat
Joined: 21 Nov 2011 Posts: 20
|
Posted: Thu Apr 19, 2012 10:01 am Post subject: [platform-dev] Re: How to have two project in one |
|
|
| Ok, I've tried to apply the instructions of the second method described in the link Javier sent (http://wiki.netbeans.org/DevFaqWrapperModules) to my situation. I have two project, the original application is a free-form java project and the plugin is a module project which is situated inside the original application's project directory. I arranged for the module a forced build of the original application and copying of the jar to the module's build\cluster\modules\ext whenever I build the module. I know that these instructions are for module library wrappers, but I was hoping they could be applicable to regular modules as well. The problem is that I don't have access from the module to the packages/classes within the imported jar. The forced build of the original application project works just fine. Here's what I actually did: |
|
| Back to top |
|
 |
Ernie Rael Posted via mailing list.
|
Posted: Thu Apr 19, 2012 2:32 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
IIUC, you want a single NBM project that includes a jar (rather than
needing two NBM). What you're describing is the right idea; note that
there should be no library wrapper involved.
In a project I've got that does this, in project.xml there is
| Quote: | <public-packages>
<package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
<class-path-extension>
<runtime-relative-path>ext/LogMan.jar</runtime-relative-path>
<binary-origin>../LogMan/dist/LogMan.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
| Could the <public-packages> be missing?
The extremely simple NBM is at http://kenai.com/projects/logman
-ernie
On 4/19/2012 2:38 AM, Martin Velek wrote:
| Quote: | Ok, I've tried to apply the instructions of the second method
described in the link Javier sent
(http://wiki.netbeans.org/DevFaqWrapperModules) to my situation. I
have two project, the original application is a free-form java project
and the plugin is a module project which is situated inside the
original application's project directory. I arranged for the module a
forced build of the original application and copying of the jar to the
module's build\cluster\modules\ext whenever I build the module. I know
that these instructions are for module library wrappers, but I was
hoping they could be applicable to regular modules as well. The
problem is that I don't have access from the module to the
packages/classes within the imported jar. The forced build of the
original application project works just fine. Here's what I actually did:
1. I adjusted <class-path-extension> in the module's project.xml.
2. I specified extra.module.files in the module's project.properties.
3. This steps wanted me to delete the module's release directory, but
there was no need since there wasn't such directory (I picked up the
jar file by modifying project.xml, build.xml and building the module
afterwards).
4. I overrode release target of the module's build.xml.
I noticed a "broken reference" in the module's project properties
dialog -> libraries -> wrapped jars. It says "broken reference:
dist/stanse.jar". What did I do wrong? What else should i set to make
it work? Thank you for your suggestions.
Best wishes
Martin Velek |
|
|
| Back to top |
|
 |
MalevolentCat
Joined: 21 Nov 2011 Posts: 20
|
Posted: Thu Apr 19, 2012 3:15 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
Hello,
there isn't a wrapper. I think this is not the problem. If I understand it, this piece of code:
<public-packages> <package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
makes the packages between <package> and </package> available for use by other modules, but this is not the case. The module itself doesn't have access to packages stored in the imported jar. But I tried it anyway, just to be sure. Here's my module's project.xml: |
|
| Back to top |
|
 |
Ernie Rael Posted via mailing list.
|
Posted: Thu Apr 19, 2012 3:26 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
The binary-origin refers to where it is built so code completion works. So I think it should be something like
<binary-origin>../../StanseNetbeans/dist/stanse.jar</binary-origin>
to refer to the original project instead of looking in the NBMs area.
On 4/19/2012 7:52 AM, Martin Velek wrote: | Quote: | Hello,
there isn't a wrapper. I think this is not the problem. If I understand it, this piece of code:
<public-packages> <package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
makes the packages between <package> and </package> available for use by other modules, but this is not the case. The module itself doesn't have access to packages stored in the imported jar. But I tried it anyway, just to be sure. Here's my module's project.xml:
| Quote: | <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>cz.muni.stanse.plugin</code-name-base>
<standalone/>
<module-dependencies/>
<public-packages/>
<class-path-extension>
<runtime-relative-path>ext/stanse.jar</runtime-relative-path>
<binary-origin>dist/stanse.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project
|
Here's what's inside the module's project.properties:
| Quote: | javac.source=1.6
javac.compilerargs=-Xlint -Xlint:-serial
extra.module.files=modules/ext/stanse.jar
|
And finally the module's build script:
| Quote: | <?xml version="1.0" encoding="UTF-8"?>
<project name="cz.muni.stanse.plugin" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project cz.muni.stanse.plugin.</description>
<import file="nbproject/build-impl.xml"/>
<property name="original.project.dir" value="../../StanseNetbeans"/>
<property name="original.project.jar"
value="${original.project.dir}/dist/stanse.jar"/>
<target name="release">
<echo message="Building ${original.project.dir}"/>
<ant dir="${original.project.dir}" usenativebasedir="true"
target="jar" inheritall="false" inheritrefs="false"/>
<echo message="Done building ${original.project.dir}"/>
<copy todir="${cluster}/modules/ext"
file="${original.project.jar}"/>
<copy todir="${cluster}/modules/ext" >
<fileset dir="${original.project.dir}/dist">
<include name="bin/**"/>
<include name="data/**"/>
<include name="lib/**"/>
<include name="www/**"/>
</fileset>
</copy>
</target>
<target name="clean" depends="projectized-common.clean">
<echo message="Cleaning ${original.project.dir}"/>
<ant dir="${original.project.dir}" usenativebasedir="true"
target="clean" inheritall="false" inheritrefs="false"/>
<echo message="Done cleaning ${original.project.dir}"/>
</target>
</project>
|
Is it a problem if the code name base of the module differs from the code name base of the project that provides the jar only in one segment. The module's code name base is cz.muni.stanse.plugin and the jar providing project's code name base is cz.muni.stanse.
The build script also copies some files to the module's ext directory along with the build of the jar providing project. I want them to be bundled with the module. Is this the correct way?
Martin
2012/4/19 Ernie Rael <address-removed ([email]address-removed[/email])>
| Quote: | IIUC, you want a single NBM project that includes a jar (rather than needing two NBM). What you're describing is the right idea; note that there should be no library wrapper involved.
In a project I've got that does this, in project.xml there is
| Quote: | <public-packages> <package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
<class-path-extension>
<runtime-relative-path>ext/LogMan.jar</runtime-relative-path>
<binary-origin>../LogMan/dist/LogMan.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
| Could the <public-packages> be missing?
The extremely simple NBM is at http://kenai.com/projects/logman
-ernie
On 4/19/2012 2:38 AM, Martin Velek wrote:
| Quote: | Ok, I've tried to apply the instructions of the second method described in the link Javier sent (http://wiki.netbeans.org/DevFaqWrapperModules) to my situation. I have two project, the original application is a free-form java project and the plugin is a module project which is situated inside the original application's project directory. I arranged for the module a forced build of the original application and copying of the jar to the module's build\cluster\modules\ext whenever I build the module. I know that these instructions are for module library wrappers, but I was hoping they could be applicable to regular modules as well. The problem is that I don't have access from the module to the packages/classes within the imported jar. The forced build of the original application project works just fine. Here's what I actually did:
1. I adjusted <class-path-extension> in the module's project.xml.
2. I specified extra.module.files in the module's project.properties.
3. This steps wanted me to delete the module's release directory, but there was no need since there wasn't such directory (I picked up the jar file by modifying project.xml, build.xml and building the module afterwards).
4. I overrode release target of the module's build.xml.
I noticed a "broken reference" in the module's project properties dialog -> libraries -> wrapped jars. It says "broken reference: dist/stanse.jar". What did I do wrong? What else should i set to make it work? Thank you for your suggestions.
Best wishes
Martin Velek
|
|
|
|
|
| Back to top |
|
 |
MalevolentCat
Joined: 21 Nov 2011 Posts: 20
|
Posted: Thu Apr 19, 2012 4:21 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
Ah, yes. Now it works, how could I not see that? I wonder how it copied the jar before (even with the wrong path), because when i checked, the jar was there, copied to the module's ext. Unfortunately, every time I try to clean and build the module, the included jar gets erased and then it won't build because of it. Any ideas how to fix that? I suppose I could copy some stable version of the original application's jar somewhere where it doesn't get deleted during the cleanup and then copy it to the module before the building starts. Finally the release target execution would replace it with the freshly built jar. Anyway thank you very much for your help!
2012/4/19 Ernie Rael <address-removed ([email]address-removed[/email])>
| Quote: | The binary-origin refers to where it is built so code completion works. So I think it should be something like
<binary-origin>../../StanseNetbeans/dist/stanse.jar</binary-origin>
to refer to the original project instead of looking in the NBMs area.
On 4/19/2012 7:52 AM, Martin Velek wrote: | Quote: | Hello,
there isn't a wrapper. I think this is not the problem. If I understand it, this piece of code:
<public-packages> <package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
makes the packages between <package> and </package> available for use by other modules, but this is not the case. The module itself doesn't have access to packages stored in the imported jar. But I tried it anyway, just to be sure. Here's my module's project.xml: |
|
| Back to top |
|
 |
MalevolentCat
Joined: 21 Nov 2011 Posts: 20
|
Posted: Thu Apr 19, 2012 4:24 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
Now I see, the build script copied the jar before, but the module had no way of knowing where the original jar was so the completion didn't work.
2012/4/19 Martin Velek <address-removed ([email]address-removed[/email])>
| Quote: | Ah, yes. Now it works, how could I not see that? I wonder how it copied the jar before (even with the wrong path), because when i checked, the jar was there, copied to the module's ext. Unfortunately, every time I try to clean and build the module, the included jar gets erased and then it won't build because of it. Any ideas how to fix that? I suppose I could copy some stable version of the original application's jar somewhere where it doesn't get deleted during the cleanup and then copy it to the module before the building starts. Finally the release target execution would replace it with the freshly built jar. Anyway thank you very much for your help!
2012/4/19 Ernie Rael <address-removed ([email]address-removed[/email])>
| Quote: | The binary-origin refers to where it is built so code completion works. So I think it should be something like
<binary-origin>../../StanseNetbeans/dist/stanse.jar</binary-origin>
to refer to the original project instead of looking in the NBMs area.
On 4/19/2012 7:52 AM, Martin Velek wrote: | Quote: | Hello,
there isn't a wrapper. I think this is not the problem. If I understand it, this piece of code:
<public-packages> <package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
makes the packages between <package> and </package> available for use by other modules, but this is not the case. The module itself doesn't have access to packages stored in the imported jar. But I tried it anyway, just to be sure. Here's my module's project.xml: |
|
| Back to top |
|
 |
MalevolentCat
Joined: 21 Nov 2011 Posts: 20
|
Posted: Thu Apr 19, 2012 4:55 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
What do you mean? I did it the same way, following the instructions there. But now I was dealing with the fact the original jar gets deleted with the clean target and the module can no longer see it so the module can't build if it uses some classes from the jar, but I fixed it already. The jar target of the original project copies the jar to some other place, where it doesn't get deleted, only rewritten with the next execution of the jar target. Everything seems to work. Thank you all very much for helping me
2012/4/19 Javier Ortiz <address-removed ([email]address-removed[/email])>
|
| Back to top |
|
 |
Ernie Rael Posted via mailing list.
|
Posted: Thu Apr 19, 2012 8:19 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
| Quote: | | every time I try to clean and build the module, the included jar gets erased and then it won't build because of it. | In my module build.xml I use the "compile" target instead of the "release" target; I think that would take care of it. Following is what the file looks like.
<import file="nbproject/build-impl.xml"/>
<property name="original.project.dir" value="../LogMan"/>
<property name="original.project.jar"
value="${original.project.dir}/dist/LogMan.jar"/>
<!-- build and retrieve the jSE jar -->
<target name="compile" depends="mycompile,projectized-common.compile"/>
<target name="mycompile">
<echo message="Building ${original.project.dir}" level="info"/>
<ant dir="${original.project.dir}"
target="jar" inheritall="false" inheritrefs="false"/>
<echo message="Done building ${original.project.dir}" level="info"/>
<echo message="Copying stuff to ${cluster}/modules/ext" level="info"/>
<copy todir="${cluster}/modules/ext"
file="${original.project.jar}"/>
</target>
<target name="clean" depends="projectized-common.clean">
<echo message="Cleaning ${original.project.dir}"/>
<ant dir="${original.project.dir}"
target="clean" inheritall="false" inheritrefs="false"/>
<echo message="Done cleaning ${original.project.dir}"/>
</target>
</project>
On 4/19/2012 8:58 AM, Martin Velek wrote: | Quote: | Ah, yes. Now it works, how could I not see that? I wonder how it copied the jar before (even with the wrong path), because when i checked, the jar was there, copied to the module's ext. Unfortunately, every time I try to clean and build the module, the included jar gets erased and then it won't build because of it. Any ideas how to fix that? I suppose I could copy some stable version of the original application's jar somewhere where it doesn't get deleted during the cleanup and then copy it to the module before the building starts. Finally the release target execution would replace it with the freshly built jar. Anyway thank you very much for your help!
2012/4/19 Ernie Rael <address-removed ([email]address-removed[/email])>
| Quote: | The binary-origin refers to where it is built so code completion works. So I think it should be something like
<binary-origin>../../StanseNetbeans/dist/stanse.jar</binary-origin>
to refer to the original project instead of looking in the NBMs area.
On 4/19/2012 7:52 AM, Martin Velek wrote: | Quote: | Hello,
there isn't a wrapper. I think this is not the problem. If I understand it, this piece of code:
<public-packages> <package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
makes the packages between <package> and </package> available for use by other modules, but this is not the case. The module itself doesn't have access to packages stored in the imported jar. But I tried it anyway, just to be sure. Here's my module's project.xml:
| Quote: | <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>cz.muni.stanse.plugin</code-name-base>
<standalone/>
<module-dependencies/>
<public-packages/>
<class-path-extension>
<runtime-relative-path>ext/stanse.jar</runtime-relative-path>
<binary-origin>dist/stanse.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project
|
Here's what's inside the module's project.properties:
| Quote: | javac.source=1.6
javac.compilerargs=-Xlint -Xlint:-serial
extra.module.files=modules/ext/stanse.jar
|
And finally the module's build script:
| Quote: | <?xml version="1.0" encoding="UTF-8"?>
<project name="cz.muni.stanse.plugin" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project cz.muni.stanse.plugin.</description>
<import file="nbproject/build-impl.xml"/>
<property name="original.project.dir" value="../../StanseNetbeans"/>
<property name="original.project.jar"
value="${original.project.dir}/dist/stanse.jar"/>
<target name="release">
<echo message="Building ${original.project.dir}"/>
<ant dir="${original.project.dir}" usenativebasedir="true"
target="jar" inheritall="false" inheritrefs="false"/>
<echo message="Done building ${original.project.dir}"/>
<copy todir="${cluster}/modules/ext"
file="${original.project.jar}"/>
<copy todir="${cluster}/modules/ext" >
<fileset dir="${original.project.dir}/dist">
<include name="bin/**"/>
<include name="data/**"/>
<include name="lib/**"/>
<include name="www/**"/>
</fileset>
</copy>
</target>
<target name="clean" depends="projectized-common.clean">
<echo message="Cleaning ${original.project.dir}"/>
<ant dir="${original.project.dir}" usenativebasedir="true"
target="clean" inheritall="false" inheritrefs="false"/>
<echo message="Done cleaning ${original.project.dir}"/>
</target>
</project>
|
Is it a problem if the code name base of the module differs from the code name base of the project that provides the jar only in one segment. The module's code name base is cz.muni.stanse.plugin and the jar providing project's code name base is cz.muni.stanse.
The build script also copies some files to the module's ext directory along with the build of the jar providing project. I want them to be bundled with the module. Is this the correct way?
Martin
2012/4/19 Ernie Rael <address-removed ([email]address-removed[/email])>
| Quote: | IIUC, you want a single NBM project that includes a jar (rather than needing two NBM). What you're describing is the right idea; note that there should be no library wrapper involved.
In a project I've got that does this, in project.xml there is
| Quote: | <public-packages> <package>com.raelity.logman</package>
<package>com.raelity.logman.ui</package>
</public-packages>
<class-path-extension>
<runtime-relative-path>ext/LogMan.jar</runtime-relative-path>
<binary-origin>../LogMan/dist/LogMan.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
| Could the <public-packages> be missing?
The extremely simple NBM is at http://kenai.com/projects/logman
-ernie
On 4/19/2012 2:38 AM, Martin Velek wrote:
| Quote: | Ok, I've tried to apply the instructions of the second method described in the link Javier sent (http://wiki.netbeans.org/DevFaqWrapperModules) to my situation. I have two project, the original application is a free-form java project and the plugin is a module project which is situated inside the original application's project directory. I arranged for the module a forced build of the original application and copying of the jar to the module's build\cluster\modules\ext whenever I build the module. I know that these instructions are for module library wrappers, but I was hoping they could be applicable to regular modules as well. The problem is that I don't have access from the module to the packages/classes within the imported jar. The forced build of the original application project works just fine. Here's what I actually did:
1. I adjusted <class-path-extension> in the module's project.xml.
2. I specified extra.module.files in the module's project.properties.
3. This steps wanted me to delete the module's release directory, but there was no need since there wasn't such directory (I picked up the jar file by modifying project.xml, build.xml and building the module afterwards).
4. I overrode release target of the module's build.xml.
I noticed a "broken reference" in the module's project properties dialog -> libraries -> wrapped jars. It says "broken reference: dist/stanse.jar". What did I do wrong? What else should i set to make it work? Thank you for your suggestions.
Best wishes
Martin Velek
|
|
|
|
|
|
|
| Back to top |
|
 |
MalevolentCat
Joined: 21 Nov 2011 Posts: 20
|
Posted: Thu Apr 19, 2012 8:44 pm Post subject: [platform-dev] Re: How to have two project in one |
|
|
Hmmm, that's more elegant solution than mine. Thank you, I will follow by your example.
Martin
2012/4/19 Ernie Rael <address-removed ([email]address-removed[/email])>
| Quote: | | Quote: | | every time I try to clean and build the module, the included jar gets erased and then it won't build because of it. |
In my module build.xml I use the "compile" target instead of the "release" target; I think that would take care of it. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|
|
| |
| | |