Skip to content

Add "heroku" in build command line to enable easy profile activation#5

Closed
jeanlaurent wants to merge 1 commit intoheroku:masterfrom
jeanlaurent:master
Closed

Add "heroku" in build command line to enable easy profile activation#5
jeanlaurent wants to merge 1 commit intoheroku:masterfrom
jeanlaurent:master

Conversation

@jeanlaurent
Copy link

I just added -Dheroku to the maven command line to enable easy detection of heroku running the build command.

This allows build to detect wether the build is run through heroku or not, with conditional profile activation like this :

<profiles>
    <profile>
        <id>heroku</id>
        <activation>
            <property>
                <name>heroku</name>
            </property>
        </activation>
       ...
    </profile>
</profiles>

Each & every application pom.xml will run with no changes, but some who wants to benefit from it, can, where before we should rely on ugly hacks (like file detection) to know wether or not the build is run through heroku.
This is useful since it speed up the build process when run outside of heroku, (most of the time the local copy dependencies is not useful during a non-heroku build, which is probably more common).

full runnning example to test the build pack :

heroku create --stack cedar --buildpack http://github.com/jeanlaurent/heroku-buildpack-java.git
with a pom.xml slighty changed from the heroku java tutorial to (we just wrapped the maven dep copy within a profile) :

<profiles>
    <profile>
        <id>heroku</id>
        <activation>
            <property>
                <name>heroku</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>package</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <stripVersion>true</stripVersion>
                                <includeScope>compile</includeScope>
                                <includeScope>runtime</includeScope>
                                <excludeScope>test</excludeScope>
                                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

running mvn clean install outside heroku is speedy as the copy dep is skipped, and it still is activated when run from heroku.

@jsimone
Copy link
Contributor

jsimone commented Apr 24, 2012

Thanks for the pull request!

I'm curious about your local workflow so that I can get the full context around this. How are you building/running in your local environment?

@jeanlaurent
Copy link
Author

Sorry I was not clear enough. Local workflow is the following :

  1. Develop in IDE.
  2. When everything is ok, run build locally to check everything is ok, I usually want this to be as fast as possible, to get instant feedback. (mvn clean package (ie I don't need the copy of dependencies at this stage)
  3. If everything is ok, push to heroku. (ie I need the copy of dependencies at this stage)

It's a kind of small optimisation, but quite cheap. I checkout the build pack code, when googling for an answers and finding http://groups.google.com/group/heroku/browse_thread/thread/1695739535398e13

hope you'll find this useful.

@jeanlaurent
Copy link
Author

As of running the webapp I'm doing it trough unit tests (test start up and shut down the app), or ran the server within the IDE.

@jsimone
Copy link
Contributor

jsimone commented May 1, 2012

I completely agree with the need for something like this. However the problem applies to more than just Java. We're currently investigating a way to solve this problem in a language agnostic manner.

I'm sure you've found the BUILDPACK_URL option and figured out that you can run your app with your build pack fork or even share that fork with others to use. I'm going to close this request, but you can run your forked build pack until we have a better solution. Please keep on eye on the Heroku changelog for updates on a better solution or other build pack changes that you may want to pull across into your fork: https://devcenter.heroku.com/changelog

@jsimone jsimone closed this May 1, 2012
tobias- pushed a commit to tobias-/heroku-buildpack-tesseract that referenced this pull request Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments